pub struct UnixNode { /* private fields */ }
Expand description
A node within a mesh that uses Unix sockets to communicate.
Each pairwise connection between two nodes in the mesh communicates via a pair of bidirectional sockets.
If one node needs to send data to another but does not have a connection, it sends a request to the leader node to establish a connection. The leader creates a new socket pair and sends one end to each of the nodes, which the two nodes can use to communicate.
Implementations§
Source§impl UnixNode
impl UnixNode
Sourcepub fn new(driver: impl SpawnDriver) -> Self
pub fn new(driver: impl SpawnDriver) -> Self
Creates a new Unix node mesh with this node as the leader.
Sourcepub fn offer_leadership(&self) -> LeadershipOffer
pub fn offer_leadership(&self) -> LeadershipOffer
Returns an offer to hand the leadership to another node in the mesh.
The offer should be sent over a channel and passed to
accept_leadership
in the receiving node.
Sourcepub fn accept_leadership(&self, offer: LeadershipOffer)
pub fn accept_leadership(&self, offer: LeadershipOffer)
Accepts a leadership offer, making this node the current leader.
Sourcepub async fn invite(&self, port: Port) -> Result<Invitation>
pub async fn invite(&self, port: Port) -> Result<Invitation>
Invites another process to join the mesh, with port
bridged with the
original port.
Sourcepub async fn join(
driver: impl SpawnDriver,
invitation: Invitation,
port: Port,
) -> Result<Self, JoinError>
pub async fn join( driver: impl SpawnDriver, invitation: Invitation, port: Port, ) -> Result<Self, JoinError>
Joins an existing mesh via an invitation, briding port
with the
initial port.
Sourcepub async fn shutdown(self)
pub async fn shutdown(self)
Shuts down the node, waiting for any sent messages to be sent to their destination.
After this call, any active ports will no longer be able to receive messages.
It is essential to call this before exiting a mesh process; until this returns, data loss could occur for other mesh nodes.