-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Most clients don't implement reconnection on error. Errors are treated as fatal and returned to the user. Given that we don't really know which errors are fatal and which are not, this seems like a reasonable behavior –- the user can just reconnect.
However, some programs may want to just ignore errors and try to reconnect indefinitely. This is useful, for example, in the case of a bridge that wants to stay up as long as possible; if one network has an outage, then it should just keep trying to reconnect to it, as it continues to bridge the other networks.
An easy way to add an option for this behavior is to make a pseudo, wrapper Client for it: the ReconnectClient. It implements the Client interface, wrapping an underlying client and adding reconnection. A ReconnectClient never returns errors. It forwards all method calls to an underlying client. If any of them fail, instead of returning an error, it either blocks or returns some trivial success message and goes into a reconnect mode where it tries to reconnect to the backend client.