broker/eats: broker disconnect fix (#1186)

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2020-02-11 18:46:50 +03:00
committed by GitHub
parent d1d6eada98
commit 2764de9a1a
2 changed files with 15 additions and 2 deletions

View File

@@ -318,7 +318,7 @@ func (n *natsBroker) Disconnect() error {
// drain the connection if specified
if n.drain {
n.conn.Drain()
return <-n.closeCh
n.closeCh <- nil
}
// close the client connection
@@ -440,6 +440,7 @@ func (n *natsBroker) setOption(opts ...broker.Option) {
n.closeCh = make(chan error)
n.nopts.ClosedCB = n.onClose
n.nopts.AsyncErrorCB = n.onAsyncError
n.nopts.DisconnectedErrCB = n.onDisconnectedError
}
}
@@ -455,6 +456,10 @@ func (n *natsBroker) onAsyncError(conn *nats.Conn, sub *nats.Subscription, err e
}
}
func (n *natsBroker) onDisconnectedError(conn *nats.Conn, err error) {
n.closeCh <- nil
}
func NewBroker(opts ...broker.Option) broker.Broker {
options := broker.Options{
// Default codec