wait nats drain since it's asynchronous
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).
This commit is contained in:
		| @@ -7,7 +7,6 @@ import ( | ||||
|  | ||||
| type optionsKey struct{} | ||||
| type drainConnectionKey struct{} | ||||
| type drainSubscriptionKey struct{} | ||||
|  | ||||
| // Options accepts nats.Options | ||||
| func Options(opts nats.Options) broker.Option { | ||||
| @@ -16,10 +15,5 @@ func Options(opts nats.Options) broker.Option { | ||||
|  | ||||
| // 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) | ||||
| 	return setBrokerOption(drainConnectionKey{}, struct{}{}) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user