-
-
Notifications
You must be signed in to change notification settings - Fork 7
Scenarios to think about #6
Description
Starting point:
- Relay started
- AB connected to relay
- Client connected to relay
Scenario 1: The Client dies and eventually reconnects.
In this case it has no idea what live data to keep feeding to the Relay/AB so AB is left without data.
Scenario 2: The Relay dies and eventually reconnects.
What should happen now? I would think the Client should stop sending(fetching from the broker) data when it disconnects from the Relay and resume when the relay is back on. But when the Relay is back on, it has no idea of the data that AB wants.
Scenario 3: AB dies and then it's restarted.
In this case it starts fresh and needs no data at all from the start. But the Client is still sending data. Knowing in the Client there is no one to consume the data, it could disconnect all live streams until further needed. Once AB is back, it could resume activity as requested by AB.
I think in case of failure someone has to remember what data is needed. My suggestion is to store this data as an object with a UNIX millisecond timestamp.
When AB wants historic or live data it updates the object/array/whatever structure with the requested data and updates the timestamp.
If the client is connected, it sends the object to the relay. The relay should also store the object. When the Client connects, it then knows what data it should send.
If AB starts fresh, the object is null or whatever with a new timestamp. This gets passed to the relay and to the client(that acts accordingly).
If this would be the approach, then when the relay dies, the client disconnects and stops all broker data fetching. When the relay is back on, it asks AB for the object of the data needed and passes it to the Client that resumes activity.
What do you think?
If anything is not clear I can explain in more detail. Or if there flaws, let me know.