[−][src]Struct netidx_protocols::cluster::Cluster
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]
publisher: &Publisher,
subscriber: Subscriber,
base: Path,
shards: usize
) -> Result<Cluster<T>>
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]
T: Send,
impl<T> Sync for Cluster<T> where
T: Sync,
[src]
T: Sync,
impl<T> Unpin for Cluster<T> where
T: Unpin,
[src]
T: Unpin,
impl<T> !UnwindSafe for Cluster<T>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,