expose useful broker and server methods
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
		| @@ -14,3 +14,13 @@ func FromContext(ctx context.Context) (Server, bool) { | ||||
| func NewContext(ctx context.Context, s Server) context.Context { | ||||
| 	return context.WithValue(ctx, serverKey{}, s) | ||||
| } | ||||
|  | ||||
| // SetServerSubscriberOption returns a function to setup a context with given value | ||||
| func SetServerSubscriberOption(k, v interface{}) SubscriberOption { | ||||
| 	return func(o *SubscriberOptions) { | ||||
| 		if o.Context == nil { | ||||
| 			o.Context = context.Background() | ||||
| 		} | ||||
| 		o.Context = context.WithValue(o.Context, k, v) | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user