mirror of
https://github.com/go-micro/go-micro.git
synced 2025-03-23 20:32:32 +02:00
22 lines
433 B
Go
22 lines
433 B
Go
package nats
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go-micro.dev/v4/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)
|
|
}
|
|
}
|