Skip to content

v0.7.0

Compare
Choose a tag to compare
@bojand bojand released this 20 Jul 02:09
· 887 commits to master since this release
bfc217c

Changelog

bfc217c Add support for call template data. Addresses #20. (#21)

Data and metadata can specify template actions that will be parsed and evaluated at every request. Each request gets a new instance of the data. The available variables / actions are:

// call template data
type callTemplateData struct {
	RequestNumber      int64  // unique incrememnted request number for each request
	FullyQualifiedName string // fully-qualified name of the method call
	MethodName         string // shorter call method name
	ServiceName        string // the service name
	InputName          string // name of the input message type
	OutputName         string // name of the output message type
	IsClientStreaming  bool   // whether this call is client streaming
	IsServerStreaming  bool   // whether this call is server streaming
	Timestamp          string // timestamp of the call in RFC3339 format
	TimestampUnix      int64  // timestamp of the call as unix time
}

This can be useful to inject variable information into the data or metadata payload for each request, such as timestamp or unique request number. Example:

$ ghz -proto ./greeter.proto -call helloworld.Greeter.SayHello -d '{"name":"Joe"}' -m '{"trace_id":"{{.RequestNumber}}","timestamp":"{{.TimestampUnix}}"}' 0.0.0.0:50051

This ends up substituting the template variables with the request number and unix timestamp respectively.


Automated with GoReleaser
Built with go version go1.10.1 darwin/amd64