Skip to main content

Crate zestors_distr_backend

Crate zestors_distr_backend 

Source
Expand description

How nodes reach each other.

A Backend is the network a cluster runs on. It is deliberately small: it connects to and accepts connections from other nodes, and a connection offers ordered, reliable, bidirectional streams and unreliable datagrams. Everything else is done for it by the cluster, the same for every backend: keeping one connection per peer, reconnecting with backoff, telling unreachable from down, ordering and framing messages, and routing them to the layer they are for.

A cluster runs over any implementation of Backend, Endpoint and Connection, handed to ClusterConfig::new in zestors-distr. The QUIC backend is in the zestors-distr-quic crate.

§What a backend must provide

  • Verified identity. Connection::peer is the node on the other end, established by the backend and not taken from the peer’s word: from a certificate, a key, or credentials. Endpoint::connect reaches the node with the given name at the given address, and fails if it isn’t that node; Endpoint::accept derives the name of whoever connected. The cluster trusts it completely, since without it any node could impersonate another.
  • Streams. Bytes written to a stream arrive complete and in order, or not at all once the connection is lost. Streams are independent: a stall on one must not hold up the others, which is what a backend with native streams gets for free, and one without has to arrange.
  • Datagrams, if it has them. A backend without returns DatagramError::Unsupported, and the cluster uses streams instead.

Structs§

NodeAddr
Where a node can be reached, in terms its backend understands.
NodeIncarnation
The node a Backend is started for.
NodeName
The name of a node in a distributed system.

Enums§

DatagramError
Why a datagram couldn’t be sent.

Traits§

Backend
A way of connecting nodes, see the module docs.
Connection
A connection to one peer.
Endpoint
A node’s presence on the network: it connects to peers and accepts theirs.

Type Aliases§

RecvStream
The receiving half of a stream. Reads to the end once the peer has shut down its half.
SendStream
The sending half of a stream. Shutting it down ends the stream, after everything written to it has been sent.