If a connection is closed, or a subscription is closed or unsubscribed,
and an error occurs at the protocol level, for instance getting a
timeout or the NATS connection is currently disconnected, etc..
the Close()/Unsubscribe() calls would return an error but the user
would not be able to invoke them again, in the sense that these
calls would bail out early because those objects were already marked
as closed.
This was problematic because if an application closes a connection for
instance but gets a timeout, then there is no way for the application
to really try to tell the server that the connection should be closed.
(same for subscription).
This PR let the user call Close()/Unsubscribe() if the library failed
to get a response from the server (likely timeout or NATS communication
issue). However, if the server returns an error, then the connection/
subscription will be considered fully closed and user won't be able
to call the close API again. The alternative would be to set the
object as fully closed only in case of total success...
Coverage decreased (-0.5%) to 92.875% when pulling df0a9c37e696cc0f2ba099208cdf6830d411f633 on close_retry_on_err into 9a6e4f20f111d75de7c9b50fe1e8143356dc797f on main.
If a connection is closed, or a subscription is closed or unsubscribed, and an error occurs at the protocol level, for instance getting a timeout or the NATS connection is currently disconnected, etc.. the Close()/Unsubscribe() calls would return an error but the user would not be able to invoke them again, in the sense that these calls would bail out early because those objects were already marked as closed.
This was problematic because if an application closes a connection for instance but gets a timeout, then there is no way for the application to really try to tell the server that the connection should be closed. (same for subscription).
This PR let the user call Close()/Unsubscribe() if the library failed to get a response from the server (likely timeout or NATS communication issue). However, if the server returns an error, then the connection/ subscription will be considered fully closed and user won't be able to call the close API again. The alternative would be to set the object as fully closed only in case of total success...
Signed-off-by: Ivan Kozlovic ivan@synadia.com