client: add call option helper

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-01-18 23:48:50 +03:00
parent 77f517a9f6
commit 2b2bcf4586
2 changed files with 12 additions and 0 deletions

View File

@@ -32,3 +32,13 @@ func SetPublishOption(k, v interface{}) PublishOption {
o.Context = context.WithValue(o.Context, k, v)
}
}
// SetCallOption returns a function to setup a context with given value
func SetCallOption(k, v interface{}) CallOption {
return func(o *CallOptions) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, k, v)
}
}