syntactic sugar

This commit is contained in:
Asim Aslam
2018-01-06 15:19:15 +00:00
committed by Vasiliy Tolstov
parent 0b9f78d3ee
commit 3d5c81f672
3 changed files with 15 additions and 17 deletions

View File

@@ -9,13 +9,12 @@ import (
type optionsKey struct{}
// Options allow to inject a nats.Options struct for configuring
// the nats connection
func Options(nopts nats.Options) broker.Option {
// Options accepts nats.Options
func Options(opts nats.Options) broker.Option {
return func(o *broker.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, optionsKey{}, nopts)
o.Context = context.WithValue(o.Context, optionsKey{}, opts)
}
}