2018-01-05 22:18:00 +03:00
|
|
|
package nats
|
|
|
|
|
|
|
|
import (
|
2020-01-31 01:26:39 +03:00
|
|
|
"github.com/micro/go-micro/v2/broker"
|
2019-05-21 15:13:58 +03:00
|
|
|
nats "github.com/nats-io/nats.go"
|
2018-01-05 22:18:00 +03:00
|
|
|
)
|
|
|
|
|
2018-01-06 15:10:43 +03:00
|
|
|
type optionsKey struct{}
|
2019-05-15 10:45:03 +03:00
|
|
|
type drainConnectionKey struct{}
|
|
|
|
type drainSubscriptionKey struct{}
|
2018-01-05 22:18:00 +03:00
|
|
|
|
2018-01-06 18:19:15 +03:00
|
|
|
// Options accepts nats.Options
|
|
|
|
func Options(opts nats.Options) broker.Option {
|
2019-01-26 13:37:58 +03:00
|
|
|
return setBrokerOption(optionsKey{}, opts)
|
2018-01-05 22:18:00 +03:00
|
|
|
}
|
2019-05-15 10:45:03 +03: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)
|
|
|
|
}
|