add useful func
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
21d5ca1cdd
commit
4c4fa00a5d
@ -15,8 +15,18 @@ func NewContext(ctx context.Context, s Server) context.Context {
|
|||||||
return context.WithValue(ctx, serverKey{}, s)
|
return context.WithValue(ctx, serverKey{}, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetServerSubscriberOption returns a function to setup a context with given value
|
// Setoption returns a function to setup a context with given value
|
||||||
func SetServerSubscriberOption(k, v interface{}) SubscriberOption {
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSubscriberOption returns a function to setup a context with given value
|
||||||
|
func SetSubscriberOption(k, v interface{}) SubscriberOption {
|
||||||
return func(o *SubscriberOptions) {
|
return func(o *SubscriberOptions) {
|
||||||
if o.Context == nil {
|
if o.Context == nil {
|
||||||
o.Context = context.Background()
|
o.Context = context.Background()
|
||||||
|
Loading…
Reference in New Issue
Block a user