client: add call option helper
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
77f517a9f6
commit
2b2bcf4586
@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/unistack-org/micro/v3/api/resolver"
|
||||
"github.com/unistack-org/micro/v3/api/resolver/vpath"
|
||||
"github.com/unistack-org/micro/v3/logger"
|
||||
"github.com/unistack-org/micro/v3/registry"
|
||||
)
|
||||
|
||||
@ -12,6 +13,7 @@ type Options struct {
|
||||
Handler string
|
||||
Registry registry.Registry
|
||||
Resolver resolver.Resolver
|
||||
Logger logger.Logger
|
||||
Context context.Context
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user