mirror of
https://github.com/go-micro/go-micro.git
synced 2024-12-12 08:23:58 +02:00
22 lines
445 B
Go
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)
|
|
}
|
|
}
|