micro-broker-nats/options.go

26 lines
639 B
Go
Raw Normal View History

2018-01-05 20:18:00 +01:00
package nats
import (
"github.com/micro/go-micro/broker"
nats "github.com/nats-io/nats.go"
2018-01-05 20:18:00 +01:00
)
type optionsKey struct{}
type drainConnectionKey struct{}
type drainSubscriptionKey struct{}
2018-01-05 20:18:00 +01:00
2018-01-06 15:19:15 +00:00
// Options accepts nats.Options
func Options(opts nats.Options) broker.Option {
return setBrokerOption(optionsKey{}, opts)
2018-01-05 20:18:00 +01:00
}
// DrainConnection will drain subscription on close
func DrainConnection() broker.Option {
return setBrokerOption(drainConnectionKey{}, true)
}
// DrainSubscription will drain pending messages when unsubscribe
func DrainSubscription() broker.SubscribeOption {
return setSubscribeOption(drainSubscriptionKey{}, true)
}