rusteron-media-driver

Crates.iorusteron-media-driver
lib.rsrusteron-media-driver
version0.1.154
created_at2024-10-26 11:09:52.190389+00
updated_at2025-09-13 10:51:37.203931+00
descriptionImplements the Aeron Media Driver, a core component for managing messaging between producers and consumers. It uses the Aeron C bindings from aeron-driver module.
homepagehttps://github.com/gsrxyz/rusteron
repositoryhttps://github.com/gsrxyz/rusteron
max_upload_size
id1423765
size22,163,711
XpertWizard (mimran1980)

documentation

https://gsrxyz.github.io/rusteron/rusteron_media_driver/index.html

README

rusteron-media-driver

rusteron-media-driver is a Rust interface to the Aeron Media Driver, responsible for managing low-latency messaging infrastructure between producers and consumers. It's part of the Rusteron project and provides both standalone and embedded driver support.

For production deployments, we recommend using the Aeron Java or C media driver.
The embedded version provided here is best suited for integration tests or lightweight environments.


Installation

To use rusteron-media-driver, add the appropriate dependency to your Cargo.toml:

Dynamic
[dependencies]
rusteron-media-driver = "0.1"
Static
[dependencies]
rusteron-media-driver = { version = "0.1", features = ["static"] }
Static with precompiled C libs (macOS only)
[dependencies]
rusteron-media-driver = { version = "0.1", features = ["static", "precompile"] }

Ensure the Aeron C libraries are properly installed and available on your system.


Usage Examples

Standard Media Driver
// Launches a standalone Aeron Media Driver
use rusteron_media_driver::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let aeron_context = AeronDriverContext::new()?;
    aeron_context.set_dir(&"target/test".into_c_string())?;

    let aeron_driver = AeronDriver::new(&aeron_context)?;
    aeron_driver.start(false)?;
    println!("Aeron Media Driver started");

    Ok(())
}
Embedded Media Driver
// Embeds the media driver directly into the current process
use rusteron_media_driver::*;
use std::sync::{Arc, atomic::{AtomicBool, Ordering}};
use std::thread;
use std::time::Duration;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let media_driver_ctx = AeronDriverContext::new()?;
    let (stop, driver_handle) = AeronDriver::launch_embedded(media_driver_ctx.clone(), false);

    let ctx = AeronContext::new()?;
    ctx.set_dir(&media_driver_ctx.get_dir().into_c_string())?;

    thread::sleep(Duration::from_secs(3)); // Simulated workload

    stop.store(true, Ordering::SeqCst);
    driver_handle.join().expect("Failed to join driver thread");
    println!("Embedded Aeron Media Driver stopped");

    Ok(())
}
Commit count: 699

cargo fmt