Interface RaftCommunication

Interface used by Raft to send messages to and receive messages from other nodes as well as to broadcast join requests to and answer join requests from other nodes.

Remark

Users can overwrite getRaftCommunicationImplementation to provide their own implementation of this interface if needed.

Hierarchy

  • RaftCommunication

Messages (one-to-one)

  • Sends the provided message to the Raft node specified by receiverId in the cluster specified by cluster. The message will be lost if the receiving node has not called startReceivingRaftMessages() yet.

    Parameters

    • message: any

      The message that should be sent. Is of type RaftData.

    • receiverId: string

      Identifies the node the message should be sent to.

    • cluster: string

      Identifies the cluster of the node the message should be sent to.

    Returns void

  • Returns an observable that can be used to observe messages sent to the Raft node specified by the provided receiverId in the cluster specified by cluster via sendRaftMessage(). The returned observable should emit all messages sent to this node after this function was called.

    Parameters

    • receiverId: string

      Specifies the Raft node whose messages will be received.

    • cluster: string

      Specifies the cluster of the Raft node whose messages will be received.

    Returns Observable<any>

    An observable that, whenever a new message has been received, emits it. The received messages should be of type RaftData.

Join Requests (one-to-many)

  • Broadcasts the provided joinRequest to all Raft nodes in the Raft cluster specified by cluster that are listening through startAcceptingJoinRequests() and returns an observable that emits whenever a listening node accepts the join request.

    Parameters

    • joinRequest: any

      The join request that should be broadcasted. Is of type RaftData.

    • cluster: string

      Specifies the cluster inside which the join request should be broadcasted.

    Returns Observable<void>

    An observable that, whenever a listening node accepts the join request, emits.

  • Returns an observable that emits whenever a new join request has been broadcasted via broadcastJoinRequest() in the cluster specified by cluster. The emitted tuple consists of the broadcasted join request together with an accept callback that can be used to signal to the broadcaster that the join request was accepted.

    Parameters

    • cluster: string

      Specifies the cluster whose broadcasted join requests should be emitted from the returned observable.

    Returns Observable<[any, (() => void)]>

    An observable that, whenever a new join request has been broadcasted, emits a tuple containing the join request and an accept callback that can be used to signal to the broadcaster that the join request was accepted. The join request should be of type RaftData.

Generated using TypeDoc