Skip to content

PeerSelection: perhaps extract logic to select peers as a protocol #496

@ktoso

Description

@ktoso

We could do

/// Peer Selection is a common step in various gossip protocols.
///
/// Selecting a peer may be as trivial as randomly selecting one among known actors or nodes,
/// round-robin cycling through peers or a mix thereof in which the order is randomized _but stable_
/// which reduces the risk of gossiping to the same or starving certain peers in situations when many
/// new peers are added to the group.
///
/// // TODO: implement SWIMs selection in terms of this
public protocol PeerSelection {
    associatedtype Peer: Hashable
    public typealias Peers = [Peer]
    associatedtype Payload: Equatable

    func onMembershipEvent(event: Cluster.Event)

    func select(for payload: Payload?) -> Peers
}

if we want to reuse it among other impls.

E.g. SWIM has a pretty good strategy and it might be good to use for our other gossips as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions