Expand description
Foca is a building block for your gossip-based cluster discovery. It’s
a small library-first crate that implements the SWIM protocol along
with its useful extensions (SWIM+Inf.+Susp.
).
-
It’s a
no_std
+alloc
crate by default. There’s an optionalstd
feature that simply brings compatibility with some types and thestd::error::Error
trait -
Bring Your Own Everything: Foca doesn’t care about anything that isn’t part of the cluster membership functionality:
-
Pluggable, renewable identities: Using a fixed port number? No need to send it all the time. Want to attach extra crucial information (shard id, deployment version, etc)? Easy. Always have a lookup table mapping
u16
to hostnames? Use that instead of a socket address! Bring your own type, implementIdentity
and enjoy. -
Write your own wire format by implementing
Codec
; Like serde? There isbincode-codec
andpostcard-codec
features, or just use theserde
feature and pick your favorite format. -
Use any transport you want, it’s up to you how messages reach each member: Foca will tell you “Send these bytes to member M”, how that happens is not its business.
-
-
Custom Broadcasts: Foca can attach arbitrary data to its messages and disseminate them the same way it distributes cluster updates. Send CRDT operations, take a stab at implementing metadata-heavy service discovery system, anything really. Give it something that implements
BroadcastHandler
and Foca will ship it. -
No runtime crashes: Apart from
alloc
-related aborts, Foca should only crash inside something you provided: aCodec
,Runtime
or aBroadcastHandler
- so long as those are solid, Foca is too. -
Doesn’t force you to choose between
sync
andasync
. It’s as easy to plug it in an evented runtime as it is to go old-school.
Structs
bincode
.NoCustomBroadcast
when any trailing byte is
found. Will be wrapped by Error
postcard
.