substrate icon indicating copy to clipboard operation
substrate copied to clipboard

Reconnecting synchronous sink

Open SpeedyCoder opened this issue 5 years ago • 3 comments

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.

SpeedyCoder avatar Mar 13 '19 15:03 SpeedyCoder

Why implement reconnection at the synchronous level?

A reconnecting async sink would be more flexible and useful in a wider set of contexts.

mjgarton avatar Mar 26 '19 12:03 mjgarton

How might this interact with suburl?

mjgarton avatar Mar 26 '19 12:03 mjgarton

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.

SpeedyCoder avatar Mar 27 '19 15:03 SpeedyCoder