2019-05-29 16:46:57 +01:00
|
|
|
package nats
|
|
|
|
|
|
|
|
import (
|
2020-01-30 14:39:00 +03:00
|
|
|
"github.com/micro/go-micro/v2/broker"
|
2019-05-29 16:46:57 +01:00
|
|
|
nats "github.com/nats-io/nats.go"
|
|
|
|
)
|
|
|
|
|
|
|
|
type optionsKey struct{}
|
|
|
|
type drainConnectionKey struct{}
|
2020-01-14 13:23:16 +00:00
|
|
|
type localServerKey struct{}
|
2019-05-29 16:46:57 +01:00
|
|
|
|
|
|
|
// Options accepts nats.Options
|
|
|
|
func Options(opts nats.Options) broker.Option {
|
|
|
|
return setBrokerOption(optionsKey{}, opts)
|
|
|
|
}
|
|
|
|
|
2020-01-14 13:23:16 +00:00
|
|
|
// LocalServer embeds a local server rather than connecting to one
|
|
|
|
func LocalServer() broker.Option {
|
|
|
|
return setBrokerOption(localServerKey{}, true)
|
|
|
|
}
|
|
|
|
|
2019-05-29 16:46:57 +01:00
|
|
|
// DrainConnection will drain subscription on close
|
|
|
|
func DrainConnection() broker.Option {
|
2019-08-07 17:58:45 +08:00
|
|
|
return setBrokerOption(drainConnectionKey{}, struct{}{})
|
2019-05-29 16:46:57 +01:00
|
|
|
}
|