[][src]Struct netidx_protocols::cluster::Cluster

pub struct Cluster<T: Serialize + DeserializeOwned + 'static> { /* fields omitted */ }

Simple clustering based on netidx. Each member publishes a uuid to a common base path, which is used to discover all other members. Commands may be sent to and received from all other members as broadcasts. On initialization all members wait until there are at least shards other members before starting operations. There can be more than shards members at any time, and members can enter and leave the cluster at will. It is up to the user to ensure state integrity under these constraints.

Messages are encoded to json, so don't expect fantastic performance.

A random cluster member is elected 'primary' by an common algorithm, the primary may change as members join and leave the cluster, but with a stable member set all members will agree on which one is the primary.

Implementations

impl<T: Serialize + DeserializeOwned + 'static> Cluster<T>[src]

pub async fn new(
    publisher: &Publisher,
    subscriber: Subscriber,
    base: Path,
    shards: usize
) -> Result<Cluster<T>>
[src]

Create a new cluster directly under base. It's wise to ensure nothing else is publishing under base.

pub fn primary(&self) -> bool[src]

Returns true if this cluster member is the primary, false otherwise. May change after poll_members.

pub fn others(&self) -> usize[src]

pub async fn poll_members(&mut self) -> Result<bool>[src]

Poll the resolvers to see if any new members have joined the cluster, return true if new members have potentially joined, false if no new members have joined.

pub async fn wait_cmds(&mut self) -> Result<Vec<T>>[src]

Wait for some commands from other members of the cluster.

pub fn send_cmd(&self, cmd: &T)[src]

Send a command out to other members of the cluster.

Auto Trait Implementations

impl<T> !RefUnwindSafe for Cluster<T>[src]

impl<T> Send for Cluster<T> where
    T: Send
[src]

impl<T> Sync for Cluster<T> where
    T: Sync
[src]

impl<T> Unpin for Cluster<T> where
    T: Unpin
[src]

impl<T> !UnwindSafe for Cluster<T>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,