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 ping message.

    We expect the reply to be an ack, upon which the onResponse

    Declaration

    Swift

    func ping(
        payload: SWIM.GossipPayload,
        from origin: SWIMPingOriginPeer,
        timeout: DispatchTimeInterval,
        sequenceNumber: SWIM.SequenceNumber,
        onResponse: @escaping (Result<SWIM.PingResponse, Error>) -> Void
    )

    Parameters

    payload

    additional gossip information to be processed by the recipient

    origin

    the 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 peer

    timeout

    timeout during which we expect the other peer to have replied to us with a PingResponse about the pinged node. If we get no response about that peer in that time, this ping is considered failed, and the onResponse MUST be invoked with a .timeout.

    onResponse

    must be invoked when the a corresponding reply (ack) or timeout event 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

    target

    target peer that should be probed by this the recipient on our behalf

    payload

    additional gossip information to be processed by the recipient

    origin

    the origin peer that has initiated this pingRequest (i.e. “myself” on the sender); replies (acks) from this indirect ping should be forwarded to it.

    timeout

    timeout during which we expect the other peer to have replied to us with a PingResponse about the pinged node. If we get no response about that peer in that time, this pingRequest is considered failed, and the onResponse MUST be invoked with a .timeout.

    onResponse

    must 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.