nats.docs icon indicating copy to clipboard operation
nats.docs copied to clipboard

Drain

Open typecampo opened this issue 3 years ago • 3 comments
trafficstars

https://docs.nats.io/using-nats/developer/receiving/drain

number 4 should be changed from Close to Unsubscribe given the implications of Unsubscribe on a durable consumer.

If it were Close then Drain would not delete the durable consumer.

see nats-io/nats.go#874

typecampo avatar Dec 15 '21 22:12 typecampo

@jnmoyne could you confirm?

gcolliso avatar Dec 16 '21 15:12 gcolliso

Technically Close is correct but I feel the steps should elaborate a little bit. Conn.Drain() performs a Drain on all subs which results in an unsubscribe as described by sub.Drain(). The unsubscribe causes the library to delete the durable consumer. So I think some mention of unsubscribe should be included in the steps of Conn.Drain() to make the reader aware that an unsubscribe will occur, not just a close of connection.

https://github.com/nats-io/nats.go/blob/41cb5bc08cf2791d7bc904af913680e96a42e70b/nats.go#L4816

typecampo avatar Dec 16 '21 15:12 typecampo

The problem is not so much the documentation as the current behavior of the library being in question. We will have to see what the conclusion of https://github.com/nats-io/nats.go/issues/874 is first and then adjust the documentation accordingly.

jnmoyne avatar Dec 17 '21 17:12 jnmoyne