Open mrjerryjohns opened 2 years ago
I've been fielding questions of late on how to assess liveness to a peer, and I think providing a construct in the SDK to help tackle that for consumers is highly valuable for 1.0.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
This stale issue has been automatically closed. Thank you for your contributions.
Problem
It is not terribly easy to infer the liveness to a peer node today, even though there are a number of signals in the SDK to make such an inference possible.
Solution
Create a new
LivenessAssessor
class that given a 'liveness timeout' parameter and a peer NodeId, can be used to figure out if we are seeing positive message activity from that peer.There are two variants here that need discussion:
These cover two different use-cases. The first just indicates a positive network pathway to the peer, as well as a valid, healthy secure session.
The second goes a step further - it ensures that we have a valid, healthy subscription to the peer.
The second is needed since just having a valid secure session to the peer doesn't necessarily imply a valid, functioning IM layer above that. The latter is a function of other parameters on the target as well.
If no activity is seen within the liveness timeout, a callback is triggered to indicate loss of liveness. If activity is seen again, the application is notified of the resumption of liveness.
A query-able stateful parameter is also provided.