micro-broker-nats/options.go
2021-01-29 18:14:34 +03:00

21 lines
390 B
Go

package nats
import (
"golang.org/x/net/context"
"github.com/micro/go-micro/broker"
"github.com/nats-io/nats"
)
type optionsKey struct{}
// 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{}, opts)
}
}