Cluster client
ergo-aeron-cluster is an experimental Rust client for Aeron Cluster. It uses
rusteron for transport and ergo-sbe-generated codecs for Aeron’s Cluster
protocol.
Hobby project. Do not use it as a production substitute for official Aeron Cluster client support.
Scope
The crate implements client-side operations:
- synchronous and poll-driven connection;
- ingress
offerand explicittry_claim; - egress polling into one listener:
AeronCluster::poll, orcontrolled_poll_egressfor per-fragment flow control; - authentication challenges and credentials;
- keep-alives and close requests;
- session events, administrative responses, and leader changes.
The Java Aeron process still provides the media driver, archive, consensus module, clustered services, election, recovery, and operational tooling. This crate implements none of those server-side components.
Where the crate sits between your loop and the Java cluster:
poll, keep_alive_if_due, offer
offer / try_claim: ingress
poll(listener): egress
keep_alive_if_due: every message_timeout / 4,
clamped to 50–1000 ms
a 32-byte session header a message
generated at build from
cluster/schemas/*.xml
exclusive publication: ingress
subscription: egress
the media driver, archive, consensus module, clustered services, election, recovery and
operational tooling. ergo-aeron-cluster implements none of those server-side components.
consensus module, clustered
services, archive, media driver
without ingress_endpoints: connect_single, one ingress channel,
blocking adds (5 s each), then the handshake until SessionEvent(OK)
with ingress_endpoints: connect_fanout, async adds to every member,
the adds and the handshake under one message_timeout deadline
CreateTransport → SendConnect → PollResponse → Done:
egress and ingress added by async adds, each step
one unit of work
a NewLeaderEvent starts an async add to the new
leader; offers fail NotConnected until it
connects, within message_timeout
Session lifecycle
Text alternative. The client has one ingress publication to the leader and one
egress subscription. Until the handshake succeeds it is Closed.
- Connect.
connect()offers oneSessionConnectRequest, which lands once, because each request opens a session. If the cluster sends aChallenge, the client answers with aChallengeResponseunder a new correlation id. ASessionEvent(OK)that echoes the current id givesConnected.message_timeoutbounds the handshake. - Keep alive.
pollnever sends keep-alives. Callkeep_alive_if_duefrom the same loop. WhileConnected, it sends a 24-byteSessionKeepAliveeverymessage_timeout / 4, clamped to 50–1000 ms. - Leader lost. When the bound egress image closes, or an offer is refused
with
NotConnectedorClosed, the state becomesAwaitingNewLeader.new_leader_timeoutbounds the wait. - New leader. A
NewLeaderEventon egress carries the new term, the leader member id and every member’s ingress endpoint. The client picks the leader’s entry, adds an ingress publication there and restarts the clock, now bounded bymessage_timeout. Once the publication connects, the client adopts the new term and leader, and the state returns toConnected. - Close.
SessionEvent(CLOSED)givesPendingClose, and the samepollthen moves it toClosed. An offer refused withMaxPositionExceededgivesPendingCloseuntil the nextpoll.close()sends aSessionCloseRequestwhileConnectedand goes straight toClosed.
Each message carries a 32-byte session header. Failover and close never block
poll, but offers fail with NotConnected from leader loss until the new
publication connects. The session closes if no NewLeaderEvent comes within
new_leader_timeout, or its publication does not connect within
message_timeout. This book records no failover timings. Endpoints and
field values in the animation are illustrative.
Features and harness
The published crate has one feature, static, on by default. It turns on
rusteron’s static feature, which links Aeron’s C into your binary, so the binary
runs with no libaeron library on the loader path. To link Aeron dynamically
instead, depend on the crate with default-features = false; then libaeron must
be on the loader path (cargo run and cargo test put it there):
ergo-aeron-cluster = { version = "0.1", default-features = false }
rusteron builds Aeron’s C from source either way, so the build needs CMake and a C
compiler. On Linux, static also links libuuid (Debian and Ubuntu: uuid-dev)
and libatomic (shipped with gcc); libbsd (libbsd-dev) is needed with or
without it.
Java Cluster launch support lives in the unpublished workspace crate
ergo-aeron-cluster-test-harness and requires a JDK (17 or newer; CI runs
Temurin 25) plus the Aeron release jars, which its build script downloads. See
Java for Archive and Cluster
for which Java to run the cluster on and the recommended JVM and Aeron settings:
just fetch-aeron-jars
just test-aeron-cluster-harness
The harness, examples, integration tests, reference codecs, and benchmarks are excluded from the published crate package.
Verify the crate
cargo test -p ergo-aeron-cluster
cargo clippy -p ergo-aeron-cluster --all-targets -- -D warnings
RUSTDOCFLAGS="-D warnings" cargo doc -p ergo-aeron-cluster --no-deps
cargo bench -p ergo-aeron-cluster --no-run
cargo package -p ergo-aeron-cluster --list --allow-dirty
Run just bench-cluster for the maintained codec comparisons. See
sbe/BENCHMARKS.md
for the common benchmark rules.
Limitations
Limitations, Aeron and rusteron versions, schema identities, failure modes and what CI runs against a live cluster: Compatibility.
Apache-2.0.