Expand description
§rusteron-archive
rusteron-archive is a module within the rusteron project that provides functionality for interacting with Aeron’s archive system in a Rust environment. This module builds on rusteron-client, adding support for recording, managing, and replaying archived streams.
§Sponsored by GSR
Rusteron is proudly sponsored and maintained by GSR, a global leader in algorithmic trading and market making in digital assets.
It powers mission-critical infrastructure in GSR’s real-time trading stack and is now developed under the official GSR GitHub organization as part of our commitment to open-source excellence and community collaboration.
We welcome contributions, feedback, and discussions. If you’re interested in integrating or contributing, please open an issue or reach out directly.
§Overview
The rusteron-archive module enables Rust developers to leverage Aeron’s archive functionality, including recording and replaying messages with minimal friction.
For MacOS users, the easiest way to get started is by using the static library with precompiled C dependencies. This avoids the need for cmake
or Java
:
rusteron-archive = { version = "0.1", features = ["static", "precompile"] }
§Installation
Add rusteron-archive to your Cargo.toml
depending on your setup:
# Dynamic linking (default)
rusteron-archive = "0.1"
# Static linking
rusteron-archive = { version = "0.1", features = ["static"] }
# Static linking with precompiled C libraries (best for Mac users, no Java/cmake needed)
rusteron-archive = { version = "0.1", features = ["static", "precompile"] }
When using the default dynamic configuration, you must ensure Aeron C libraries are available at runtime. The static
option embeds them automatically into the binary.
§Development
To simplify development, we use just
, a command runner similar to make
.
To view all available commands, run just
in the command line.
If you don’t have
just
installed, install it with:cargo install just
§Features
- Stream Recording – Record Aeron streams for replay or archival.
- Replay Handling – Replay previously recorded messages.
- Publication/Subscription – Publish to and subscribe from Aeron channels.
- Callbacks – Receive events such as new publications, subscriptions, and errors.
- Automatic Resource Management (via
new()
only) – Constructors automatically call*_init
and clean up with*_close
or*_destroy
when dropped. - String Handling –
new()
and setter methods accept&CStr
; getter methods return&str
.
§General Patterns
§Cloneable Wrappers
All wrapper types in rusteron-archive implement Clone
and share the same underlying Aeron C resource. For shallow copies of raw structs, use .clone_struct()
.
§Mutable and Immutable APIs
Most methods use &self
, allowing mutation without full ownership transfer.
§Resource Management Caveats
Automatic cleanup applies only to new()
constructors. Other methods (e.g. set_aeron()
) require manual lifetime and validity tracking to prevent resource misuse.
§Manual Handler Management
Handlers must be passed into C bindings using Handlers::leak(...)
and explicitly cleaned up using release()
when no longer needed.
For short-lived operations such as polling, closures can be used directly:
subscription.poll_once(|msg, header| {
println!("msg={:?}, header={:?}", msg, header)
});
§Handlers and Callbacks
There are two primary patterns for defining callbacks:
§1. Trait-Based Handlers (Recommended)
The preferred and most efficient approach is to define a trait and implement it for a struct:
use rusteron_archive::*;
pub trait AeronErrorHandlerCallback {
fn handle_aeron_error_handler(&mut self, errcode: ::std::os::raw::c_int, message: &str);
}
pub struct AeronErrorHandlerLogger;
impl AeronErrorHandlerCallback for AeronErrorHandlerLogger {
fn handle_aeron_error_handler(&mut self, errcode: ::std::os::raw::c_int, message: &str) {
eprintln!("Error {}: {}", errcode, message);
}
}
You then wrap the implementation in a handler using Handlers::leak(...)
.
§2. Wrapping Callbacks with Handler
Regardless of approach, callbacks must be wrapped in a Handler
to interact with Aeron’s C bindings. Use Handlers::leak(...)
to pass it into the system, and call release()
once cleanup is needed.
§Handler Convenience Methods
You can pass None
if a handler isn’t required, but dealing with typed Option
s can be awkward. rusteron-archive offers helpers like:
pub fn no_error_handler_handler() -> Option<&'static Handler<AeronErrorHandlerLogger>> {
None::<&Handler<AeronErrorHandlerLogger>>
}
These helpers return None
with the correct generic type to reduce boilerplate.
§Error Handling with Aeron C Bindings
Operations in rusteron-archive return Result<i32, AeronCError>
, using idiomatic Rust error types.
§AeronErrorType Enum
Variant | Description |
---|---|
NullOrNotConnected | Null value or unconnected |
ClientErrorDriverTimeout | Driver timed out |
ClientErrorClientTimeout | Client timed out |
ClientErrorConductorServiceTimeout | Conductor service timeout |
ClientErrorBufferFull | Buffer full |
PublicationBackPressured | Publication is back-pressured |
PublicationAdminAction | Admin action in progress |
PublicationClosed | Publication has closed |
PublicationMaxPositionExceeded | Max position exceeded |
PublicationError | Generic publication error |
TimedOut | Timeout occurred |
Unknown(i32) | Unrecognized error code |
The AeronCError
struct exposes these enums alongside descriptive messages.
§Safety Considerations
- Aeron Lifetime – The
AeronArchive
depends on an externalAeron
instance. EnsureAeron
outlives all references to the archive. - Unsafe Bindings – The module interfaces directly with Aeron’s C API. Improper resource handling can cause undefined behavior.
- Manual Cleanup – Handlers and other leaked objects must be manually cleaned up using
.release()
. - Thread Safety – Use care when accessing Aeron objects across threads. Synchronize access appropriately.
§Typical Workflow
- Initialize client and archive contexts.
- Start Recording a specific channel and stream.
- Publish Messages to the stream.
- Stop Recording once complete.
- Locate the Recording using archive queries.
- Replay Setup: Configure replay target/channel.
- Subscribe and Receive replayed messages.
§Benchmarks
For latency and throughput benchmarks, refer to BENCHMARKS.md.
§Contributing
Contributions are more than welcome! Please:
- Submit bug reports, ideas, or improvements via GitHub Issues
- Propose changes via pull requests
- Read our CONTRIBUTING.md
We’re especially looking for help with:
- API design reviews
- Safety and idiomatic improvements
- Dockerized and deployment examples
§License
Licensed under either MIT License or Apache License 2.0 at your option.
§Acknowledgments
Special thanks to:
- @mimran1980, a core low-latency developer at GSR and the original creator of Rusteron - your work made this possible!
- @bspeice for the original
libaeron-sys
- The Aeron community for open protocol excellence
§Features
static
: When enabled, this feature statically links the Aeron C code. By default, the library uses dynamic linking to the Aeron C libraries.backtrace
- When enabled will log a backtrace for each AeronCErrorextra-logging
- When enabled will log when resource is created and destroyed. useful if your seeing a segfault due to a resource being closedprecompile
- When enabled will use precompiled c code instead of requiring cmake and java to me installed
Modules§
Structs§
- Aeron
- Aeron
Agent Start Func Logger - Aeron
Archive - Aeron
Archive Async Connect - Aeron
Archive Context - Aeron
Archive Control Response Poller - Aeron
Archive Credentials Challenge Supplier Func Logger - Aeron
Archive Credentials Encoded Credentials Supplier Func Logger - Aeron
Archive Credentials Free Func Logger - Aeron
Archive Delegating Invoker Func Logger - Aeron
Archive Encoded Credentials - Aeron
Archive Proxy - Aeron
Archive Recording Descriptor - Struct containing the details of a recording
- Aeron
Archive Recording Descriptor Consumer Func Logger - Aeron
Archive Recording Descriptor Poller - Aeron
Archive Recording Signal - Struct containing the details of a recording signal.
- Aeron
Archive Recording Signal Consumer Func Logger - Aeron
Archive Recording Subscription Descriptor - Struct containing the details of a recording subscription
- Aeron
Archive Recording Subscription Descriptor Consumer Func Logger - Aeron
Archive Recording Subscription Descriptor Poller - Aeron
Archive Replay Merge - Aeron
Archive Replay Params - Struct containing the available replay parameters.
- Aeron
Archive Replication Params - Struct containing the available replication parameters.
- Aeron
Async AddCounter - Aeron
Async AddExclusive Publication - Aeron
Async AddPublication - Aeron
Async AddSubscription - Aeron
Async Destination - Aeron
Async Destination ById - Aeron
Available Counter Logger - Aeron
Available Counter Pair - Aeron
Available Image Logger - Aeron
Block Handler Logger - Aeron
Buffer Claim - Structure used to hold information for a try_claim function call.
- AeronC
Error - Represents an Aeron-specific error with a code and an optional message.
- Aeron
Client Registering Resource - Aeron
Close Client Logger - Aeron
Close Client Pair - Aeron
Cnc - Aeron
CncConstants - Aeron
CncMetadata - Aeron
Context - Aeron
Controlled Fragment Assembler - Aeron
Controlled Fragment Handler Logger - Aeron
Counter - Aeron
Counter Constants - Configuration for a counter that does not change during it’s lifetime.
- Aeron
Counter Metadata Descriptor - Aeron
Counter Value Descriptor - Aeron
Counters Reader - Aeron
Counters Reader Buffers - Aeron
Counters Reader Foreach Counter Func Logger - Aeron
Data Header - Aeron
Data Header AsLongs - Aeron
Error - Aeron
Error Handler Logger - Aeron
Error LogReader Func Logger - Aeron
Error Logger - Aeron
Exclusive Publication - Aeron
Fragment Assembler - Aeron
Fragment Closure Assembler - Aeron
Fragment Handler Logger - Aeron
Frame Header - Aeron
Header - Aeron
Header Values - Aeron
Header Values Frame - Aeron
Idle Strategy Func Logger - Aeron
Image - Aeron
Image Constants - Configuration for an image that does not change during it’s lifetime.
- Aeron
Image Controlled Fragment Assembler - Aeron
Image Fragment Assembler - Aeron
Iovec - Aeron
IpcChannel Params - Aeron
LogBuffer - Aeron
Logbuffer Metadata - Aeron
Loss Reporter - Aeron
Loss Reporter Entry - Aeron
Loss Reporter Read Entry Func Logger - Aeron
Mapped Buffer - Aeron
Mapped File - Aeron
Mapped RawLog - Aeron
NakHeader - Aeron
NewPublication Logger - Aeron
NewSubscription Logger - Aeron
Notification Logger - Aeron
Option Header - Aeron
PerThread Error - Aeron
Publication - Aeron
Publication Constants - Configuration for a publication that does not change during it’s lifetime.
- Aeron
Publication Error Frame Handler Logger - Aeron
Publication Error Values - Aeron
Reserved Value Supplier Logger - Aeron
Resolution Header - Aeron
Resolution Header Ipv4 - Aeron
Resolution Header Ipv6 - Aeron
Response Setup Header - Aeron
Rttm Header - Aeron
Setup Header - Aeron
Status Message Header - Aeron
Status Message Optional Header - Aeron
StrTo PtrHash Map - Aeron
StrTo PtrHash MapKey - Aeron
Subscription - Aeron
Subscription Constants - Aeron
UdpChannel Params - Aeron
Unavailable Counter Logger - Aeron
Unavailable Counter Pair - Aeron
Unavailable Image Logger - Aeron
Uri - Aeron
UriParam - Aeron
UriParams - Aeron
UriParse Callback Logger - Aeron
UriString Builder - Atomic
Wide Counter Bindgen Ty1 - Channel
Uri - Represents the Aeron URI parser and handler.
- FnMut
Message Handler - Handler
- Handler
- Handlers
- Utility method for setting empty handlers
- ManagedC
Resource - A custom struct for managing C resources with automatic cleanup.
- NoOp
Aeron Idle Strategy Func - Pthread
CondS - Pthread
Internal List - Pthread
MutexS - Recording
Pos
Enums§
- Aeron
Error Type - Aeron
System Counter Type - CResource
- Control
Mode - Enum for control modes.
- Media
- Enum for media types.
Constants§
- AERON_
DIR_ PROP_ NAME - AERON_
IPC_ MEDIA - AERON_
UDP_ MEDIA - DRIVER_
TIMEOUT_ MS_ DEFAULT - SOURCE_
LOCATION_ LOCAL - SOURCE_
LOCATION_ REMOTE - SPY_
PREFIX - TAG_
PREFIX
Statics§
Traits§
- Aeron
Agent Start Func Callback - (note you must copy any arguments that you use afterwards even those with static lifetimes)
- Aeron
Archive Credentials Challenge Supplier Func Callback - Callback to return encoded credentials given a specific encoded challenge.
- Aeron
Archive Credentials Encoded Credentials Supplier Func Callback - Callback to return encoded credentials.
- Aeron
Archive Credentials Free Func Callback - Callback to return encoded credentials so they may be reused or freed.
- Aeron
Archive Delegating Invoker Func Callback - Callback to allow execution of a delegating invoker to be run.
- Aeron
Archive Recording Descriptor Consumer Func Callback - Callback to return recording descriptors.
- Aeron
Archive Recording Signal Consumer Func Callback - Callback to return recording signals.
- Aeron
Archive Recording Subscription Descriptor Consumer Func Callback - Callback to return recording subscription descriptors.
- Aeron
Available Counter Callback - Function called by aeron_client_t to deliver notifications that a counter has been added to the driver.
- Aeron
Available Image Callback - Function called by aeron_client_t to deliver notifications that an aeron_image_t was added.
- Aeron
Block Handler Callback - Callback for handling a block of messages being read from a log.
- Aeron
Close Client Callback - Function called by aeron_client_t to deliver notifications that the client is closing.
- Aeron
Controlled Fragment Handler Callback - Callback for handling fragments of data being read from a log.
- Aeron
Counters Reader Foreach Counter Func Callback - Function called by aeron_counters_reader_foreach_counter for each counter in the aeron_counters_reader_t.
- Aeron
Error Handler Callback - The error handler to be called when an error occurs.
- Aeron
Error LogReader Func Callback - (note you must copy any arguments that you use afterwards even those with static lifetimes)
- Aeron
Fragment Handler Callback - Callback for handling fragments of data being read from a log.
- Aeron
Idle Strategy Func Callback - (note you must copy any arguments that you use afterwards even those with static lifetimes)
- Aeron
Loss Reporter Read Entry Func Callback - (note you must copy any arguments that you use afterwards even those with static lifetimes)
- Aeron
NewPublication Callback - Function called by aeron_client_t to deliver notification that the media driver has added an aeron_publication_t or aeron_exclusive_publication_t successfully.
- Aeron
NewSubscription Callback - Function called by aeron_client_t to deliver notification that the media driver has added an aeron_subscription_t successfully.
- Aeron
Notification Callback - Generalised notification callback.
- Aeron
Publication Error Frame Handler Callback - The error frame handler to be called when the driver notifies the client about an error frame being received.
The data passed to this callback will only be valid for the lifetime of the callback. The user should use
aeron_publication_error_values_copy
if they require the data to live longer than that. - Aeron
Reserved Value Supplier Callback - Function called when filling in the reserved value field of a message.
- Aeron
Unavailable Counter Callback - Function called by aeron_client_t to deliver notifications that a counter has been removed from the driver.
- Aeron
Unavailable Image Callback - Function called by aeron_client_t to deliver notifications that an aeron_image_t has been removed from use and should not be used any longer.
- Aeron
UriParse Callback Callback - (note you must copy any arguments that you use afterwards even those with static lifetimes)
- IntoC
String