package
0.120.0
Repository: https://github.com/bojand/ghz.git
Documentation: pkg.go.dev

# Functions

LoadConfig loads the config from a file.
NewConfig creates a new RunConfig from the options passed.
NewRequester creates a new requestor from the passed RunConfig.
ReasonFromString creates a Status from a string.
Run executes the test report, err := runner.Run( "helloworld.Greeter.SayHello", "localhost:50051", WithProtoFile("greeter.proto", []string{}), WithDataFromFile("data.json"), WithInsecure(true), ).
WithAsync specifies the async option.
WithAuthority specifies the value to be used as the :authority pseudo-header.
WithBinaryData specifies the binary data msg := &helloworld.HelloRequest{} msg.Name = "bob" binData, _ := proto.Marshal(msg) WithBinaryData(binData).
WithBinaryDataFromFile specifies the binary data WithBinaryDataFromFile("request_data.bin").
WithBinaryDataFunc specifies the binary data func which will be called on each request WithBinaryDataFunc(changeFunc).
WithCertificate specifies the certificate options for the run WithCertificate("client.crt", "client.key").
WithClientLoadBalancing specifies the LB strategy to use The strategies has to be self written and pre defined.
WithConcurrency specifies the C (number of concurrent requests) option WithConcurrency(20).
WithConcurrencyDuration specifies the total concurrency adjustment duration.
WithConcurrencyEnd specifies the concurrency end value for line or step schedule WithConcurrencyEnd(25).
WithConcurrencySchedule specifies the concurrency adjustment schedule WithConcurrencySchedule("const").
WithConcurrencyStart specifies the concurrency start for line or step schedule WithConcurrencyStart(5).
WithConcurrencyStep specifies the concurrency step value or slope WithConcurrencyStep(5).
WithConcurrencyStepDuration specifies the concurrency step duration for step schedule.
WithConfig uses the configuration to populate the RunConfig See also: WithConfigFromFile, WithConfigFromReader.
WithConfigFromFile uses a configuration JSON file to populate the RunConfig WithConfigFromFile("config.json").
WithConfigFromReader uses a reader containing JSON data to populate the RunConfig See also: WithConfigFromFile.
WithConnections specifies the number of gRPC connections to use WithConnections(5).
WithCountErrors is the count errors option.
WithCPUs specifies the number of CPU's to be used WithCPUs(4).
WithData specifies data as generic data that can be serailized to JSON.
WithDataFromFile loads JSON data from file WithDataFromFile("data.json").
WithDataFromJSON loads JSON data from string WithDataFromJSON(`{"name":"bob"}`).
WithDataFromReader loads JSON data from reader file, _ := os.Open("data.json") WithDataFromReader(file).
WithDataProvider provides custom data provider WithDataProvider(func(*CallData) ([]*dynamic.Message, error) { protoMsg := &helloworld.HelloRequest{Name: "Bob"} dynamicMsg, err := dynamic.AsDynamicMessage(protoMsg) if err != nil { return nil, err } return []*dynamic.Message{dynamicMsg}, nil }),.
WithDefaultCallOptions sets the default CallOptions for calls over the connection.
WithDialTimeout specifies the initial connection dial timeout WithDialTimeout(time.Duration(20*time.Second)).
WithDisableTemplateData disables template data execution in call data.
WithDisableTemplateFuncs disables template functions in call data.
WithDurationStopAction specifies how run duration (Z) timeout is handled Possible options are "close", "ignore", and "wait" WithDurationStopAction("ignore").
WithEnableCompression specifies that requests should be done using gzip Compressor WithEnableCompression(true).
WithInsecure specifies that this run should be done using insecure mode WithInsecure(true).
WithKeepalive specifies the keepalive timeout WithKeepalive(time.Duration(1*time.Minute)).
WithLoadDuration specifies the load duration.
WithLoadEnd specifies the load end WithLoadEnd(25).
WithLoadSchedule specifies the load schedule WithLoadSchedule("const").
WithLoadStart specifies the load start WithLoadStart(5).
WithLoadStep specifies the load step WithLoadStep(5).
WithLoadStepDuration specifies the load step duration for step schedule.
WithLogger specifies the logging option.
WithMetadata specifies the metadata to be used as a map md := make(map[string]string) md["token"] = "foobar" md["request-id"] = "123" WithMetadata(&md).
WithMetadataFromFile loads JSON metadata from file WithMetadataFromJSON("metadata.json").
WithMetadataFromJSON specifies the metadata to be read from JSON string WithMetadataFromJSON(`{"request-id":"123"}`).
WithMetadataProvider provides custom metadata provider WithMetadataProvider(ctd *CallData) (*metadata.MD, error) { return &metadata.MD{"token": []string{"secret"}}, nil }),.
WithName sets the name of the test run WithName("greeter service test").
WithPacer specified the custom pacer to use.
WithProtoFile specified proto file path and optionally import paths We will automatically add the proto file path's directory and the current directory WithProtoFile("greeter.proto", []string{"/home/protos"}).
WithProtoset specified protoset file path WithProtoset("bundle.protoset").
WithReflectionMetadata specifies the metadata to be used as a map md := make(map[string]string) md["token"] = "foobar" md["request-id"] = "123" WithReflectionMetadata(&md).
WithRootCertificate specifies the root certificate options for the run WithRootCertificate("ca.crt").
WithRPS specifies the RPS (requests per second) limit option WithRPS(10).
WithRunDuration specifies the Z (total test duration) option WithRunDuration(time.Duration(2*time.Minute)).
WithServerNameOverride specifies the certificate options for the run.
WithSkipFirst is the skipFirst option.
WithSkipTLSVerify skip client side TLS verification of server certificate.
WithStreamCallCount sets the stream close count.
WithStreamCallDuration sets the maximum stream call duration at which point the client will close the stream.
WithStreamDynamicMessages sets the stream dynamic message generation.
WithStreamInterceptor specifies the stream interceptor provider function.
WithStreamInterval sets the stream interval.
WithStreamMessageProvider sets custom stream message provider WithStreamMessageProvider(func(cd *CallData) (*dynamic.Message, error) { protoMsg := &helloworld.HelloRequest{Name: cd.WorkerID + ": " + strconv.FormatInt(cd.RequestNumber, 10)} dynamicMsg, err := dynamic.AsDynamicMessage(protoMsg) if err != nil { return nil, err } callCounter++ if callCounter == 5 { err = ErrLastMessage } return dynamicMsg, err }),.
WithStreamRecvMsgIntercept specified the stream receive intercept function WithStreamRecvMsgIntercept(func(msg *dynamic.Message, err error) error { if err == nil && msg != nil { reply := &helloworld.HelloReply{} convertErr := msg.ConvertTo(reply) if convertErr == nil { if reply.GetMessage() == "Hello bar" { return ErrEndStream } } } return nil }).
WithTags specifies the user defined tags as a map tags := make(map[string]string) tags["env"] = "staging" tags["created by"] = "joe developer" WithTags(&tags).
WithTemplateFuncs adds additional template functions.
WithTimeout specifies the timeout for each request WithTimeout(time.Duration(20*time.Second)).
WithTotalRequests specifies the N (number of total requests) setting WithTotalRequests(1000).
WithWorkerTicker specified the custom worker ticker to use.

# Constants

ReasonCancel indicates end due to cancellation.
ReasonNormalEnd indicates a normal end to the run.
ReasonTimeout indicates run ended due to Z parameter timeout.
ScheduleConst is a constant load schedule.
ScheduleLine is the line load schedule.
ScheduleStep is the step load schedule.

# Variables

ErrEndStream is a signal from message providers that worker should close the stream It should not be used for erronous states.
ErrLastMessage is a signal from message providers that the returned payload is the last one of the stream This is optional but encouraged for optimized performance Message payload returned along with this error must be valid and may not be nil.

# Structs

Bucket holds histogram data.
CallData represents contextualized data available for templating.
Config for the run.
Counter is an implementation of the request counter.
LatencyDistribution holds latency distribution data.
Options represents the request options TODO fix casing and consistency.
Report holds the data for the full test.
Reporter gathers all the results.
Requester is used for doing the requests.
ResultDetail data for each result.
RunConfig represents the request Configs.
TickValue is the tick value.
Worker is used for doing a single stream of requests in parallel.

# Interfaces

Logger interface is the common logger interface for all of web.
RequestCounter gets the request count.
StreamInterceptor is an interface for sending and receiving stream messages.

# Type aliases

BinaryDataFunc is a function that can be used for provide binary data for request programatically.
DataProviderFunc is the interface for providing data for calls For unary and server streaming calls it should return an array with a single element For client and bidi streaming calls it should return an array of messages to be used.
Duration is our duration with TOML support.
MetadataProviderFunc is the interface for providing metadadata for calls.
Option controls some aspect of run.
StopReason is a reason why the run ended.
StreamInterceptorProviderFunc is an interface for a function invoked to generate a stream interceptor.
StreamMessageProviderFunc is the interface for providing a message for every message send in the course of a streaming call.
StreamRecvMsgInterceptFunc is an interface for function invoked when we receive a stream message Clients can return ErrEndStream to end the call early.