client: add option helper

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2021-01-19 00:45:55 +03:00
parent 2b2bcf4586
commit 4783c6d9a3

View File

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