1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-12 08:23:58 +02:00
go-micro/plugins/transport/nats/options.go
2021-01-20 21:01:10 +00:00

22 lines
445 B
Go

package nats
import (
"context"
"github.com/asim/go-micro/v3/transport"
"github.com/nats-io/nats.go"
)
type optionsKey struct{}
// Options allow to inject a nats.Options struct for configuring
// the nats connection
func Options(nopts nats.Options) transport.Option {
return func(o *transport.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, optionsKey{}, nopts)
}
}