mirror of
https://github.com/go-micro/go-micro.git
synced 2024-12-24 10:07:04 +02:00
0baea58938
1. nats subscription draining is removed, since it is asynchronous, and there is no reliable way to detect when it is finished. Remove this option to avoid confusion. 2. nats connection draining is kept, and use 2 callbacks to detect draining timeout (timeout is set via `nats.Options`) or finish. 3. Also honour options passed in `broker.Init()` (previously only `broker.New()` is honoured).
20 lines
434 B
Go
20 lines
434 B
Go
package nats
|
|
|
|
import (
|
|
"github.com/micro/go-micro/broker"
|
|
nats "github.com/nats-io/nats.go"
|
|
)
|
|
|
|
type optionsKey struct{}
|
|
type drainConnectionKey struct{}
|
|
|
|
// Options accepts nats.Options
|
|
func Options(opts nats.Options) broker.Option {
|
|
return setBrokerOption(optionsKey{}, opts)
|
|
}
|
|
|
|
// DrainConnection will drain subscription on close
|
|
func DrainConnection() broker.Option {
|
|
return setBrokerOption(drainConnectionKey{}, struct{}{})
|
|
}
|