SWIMPeer
public protocol SWIMPeer : SWIMAddressablePeer
SWIM peer which can be initiated contact with, by sending ping or ping request messages.
-
Perform a probe of this peer by sending a
pingmessage.We expect the reply to be an
ack, upon which theonResponseDeclaration
Swift
func ping( payload: SWIM.GossipPayload, from origin: SWIMPingOriginPeer, timeout: DispatchTimeInterval, sequenceNumber: SWIM.SequenceNumber, onResponse: @escaping (Result<SWIM.PingResponse, Error>) -> Void )Parameters
payloadadditional gossip information to be processed by the recipient
originthe origin peer that has initiated this ping message (i.e. “myself” of the sender) replies (
acks) from to this ping should be send to this peertimeouttimeout during which we expect the other peer to have replied to us with a
PingResponseabout the pinged node. If we get no response about that peer in that time, thispingis considered failed, and the onResponse MUST be invoked with a.timeout.onResponsemust be invoked when the a corresponding reply (
ack) ortimeoutevent for this ping occurs. No guarantees about concurrency or threading are made with regards to where/how this invocation will take place, so implementation shells may want to hop to the right executor or protect their state using some other way when before handling the response. -
Send a ping request to this peer, asking it to perform an “indirect ping” of the target on our behalf.
Any resulting acknowledgements back to us. If not acknowledgements come back from the target, the intermediary may send back nack messages, indicating that our connection to the intermediary is intact, however we didn’t see acknowledgements from the target itself.
Declaration
Swift
func pingRequest( target: SWIMPeer, payload: SWIM.GossipPayload, from origin: SWIMPingRequestOriginPeer, timeout: DispatchTimeInterval, sequenceNumber: SWIM.SequenceNumber, onResponse: @escaping (Result<SWIM.PingResponse, Error>) -> Void )Parameters
targettarget peer that should be probed by this the recipient on our behalf
payloadadditional gossip information to be processed by the recipient
originthe origin peer that has initiated this
pingRequest(i.e. “myself” on the sender); replies (acks) from this indirect ping should be forwarded to it.timeouttimeout during which we expect the other peer to have replied to us with a
PingResponseabout the pinged node. If we get no response about that peer in that time, thispingRequestis considered failed, and the onResponse MUST be invoked with a.timeout.onResponsemust be invoked when the a corresponding reply (ack, nack) or timeout event for this ping request occurs. No guarantees about concurrency or threading are made with regards to where/how this invocation will take place, so implementation shells may want to hop to the right executor or protect their state using some other way when before handling the response.
View on GitHub
SWIMPeer Protocol Reference