2018-01-05 22:18:00 +03:00
|
|
|
package nats
|
|
|
|
|
|
|
|
import (
|
2018-03-03 15:28:44 +03:00
|
|
|
"context"
|
2018-01-06 15:10:43 +03:00
|
|
|
|
2018-01-05 22:18:00 +03:00
|
|
|
"github.com/micro/go-micro/broker"
|
2018-06-12 02:15:24 +03:00
|
|
|
"github.com/nats-io/go-nats"
|
2018-01-05 22:18:00 +03:00
|
|
|
)
|
|
|
|
|
2018-01-06 15:10:43 +03:00
|
|
|
type optionsKey struct{}
|
2018-01-05 22:18:00 +03:00
|
|
|
|
2018-01-06 18:19:15 +03:00
|
|
|
// Options accepts nats.Options
|
|
|
|
func Options(opts nats.Options) broker.Option {
|
2018-01-05 22:18:00 +03:00
|
|
|
return func(o *broker.Options) {
|
2018-01-06 15:10:43 +03:00
|
|
|
if o.Context == nil {
|
|
|
|
o.Context = context.Background()
|
|
|
|
}
|
2018-01-06 18:19:15 +03:00
|
|
|
o.Context = context.WithValue(o.Context, optionsKey{}, opts)
|
2018-01-05 22:18:00 +03:00
|
|
|
}
|
|
|
|
}
|