Simple expendable passive requests
A very simple means to implement passive requests. Does not provide true persistence.
When a request fails, with the passive request enabled, we record a passive request entry:
- the key
- the node which sent the request to us
- the nodes which we sent the request to
- the time (the request will disappear after a certain period)
If we get the key later on, then we send it to all the nodes which have requested the key from us.
If a node disconnects:
- If it had sent the request to us, we remove it from the set of nodes which have requested the key. If the set of nodes which have requested the key is then empty, we remove the passive request entry, because nobody is listening any more, and we tell each of the nodes which we have sent requests to for this key that to unsubscribe us.
- If we had sent a request to it, we remove it from the list of nodes we have sent requests for this key to.
A node can send us an unsubscribe message; if we get one, we remove that node from the list of nodes which sent the request to us, and if they are all gone, we remove the passive request entry, and tell all the nodes we have sent the request to that we are unsubscribing from them too.
Now, why does this not provide true persistence? We never re-route a request. If the locations of our adjacent nodes change so that the request should have been routed differently, we don't change it. If a new node connects which we should have routed the request to, we don't change it either, and if a node disconnects, we don't route to the next-best. We rely entirely on new requests to establish the correct route. A truly persistent passive request would automatically reroute so that the clients don't have to keep on polling. So, this simplest possible passive requests implementation doesn't completely solve the "load caused by polling" problem; clients will have to send more requests from time to time, but it DOES reduce the polling latency, to the point that near-real-time applications (e.g. publish/subscribe streams used for for example broadcast audio streaming) should become feasible.