substrate
substrate copied to clipboard
Reconnecting synchronous sink
Add experimental version of synchronous sink adapter that automatically reconnects on failures using the provided backoff strategy. It also periodically checks the status of the underlying async sink and reconnects as necessary. I've just quickly put this together, so it's not fully tested yet, but I think it should work. It's a breaking change so I've put it to experimental folder for now.
Why implement reconnection at the synchronous level?
A reconnecting async sink would be more flexible and useful in a wider set of contexts.
How might this interact with suburl
?
The reason why I've implemented it at the synchronous level is that I can just return error to any pending write calls, when the sink is disconnected, as I don't know whether the message was sent successfully. This is not possible in the asynchronous case as then I can only send an acknowledgement. We could do something similar for async sink, but in that case we could only reconnect when there are no pending messages.
We could make this a parameter in the suburl, so that the resulting sink is wrapped in the reconnecting one.