Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
rusteron-archive
rusteron-archive is a module within the rusteron project that provides functionalities for interacting with Aeron's archive capabilities in a Rust environment. This module aims to extend rusteron-client by offering features for recording streams, managing archives, and handling replay capabilities.
Overview
The rusteron-archive module is intended to help Rust developers leverage Aeron's archive functionalities, including the recording and replaying of messages. However, this module is currently in an early stage and has not been thoroughly tested.
The code in rusteron-archive is generated as a Rust wrapper around the Aeron C archive API, making it easier for Rust developers to work with Aeron's archiving capabilities. Since this module also uses C bindings, it involves an unsafe
context, and extra caution is advised when using it.
Installation
To use rusteron-archive, add it to your Cargo.toml
:
dynamic lib
[]
= "0.1"
static lib
[]
= { = "0.1", = ["static"] }
Ensure that you have also set up the necessary Aeron C libraries required by rusteron-archive.
Features
- Stream Recording: Enables recording of Aeron streams.
- Replay Handling: Provides capabilities for replaying recorded messages.
Safety Considerations
Resource Management for AeronArchive: The current implementation has a critical limitation: the Aeron
object must be kept alive explicitly. The AeronArchive
does not take ownership or manage its lifetime correctly. Instead of passing the Aeron
instance through the constructor, the set_aeron
function is used, which can lead to potential segmentation faults if the Aeron
instance is prematurely dropped. Extra caution is required to ensure the Aeron
instance remains valid during the lifetime of the AeronArchive
.
Since rusteron-archive relies on Aeron C bindings, it uses unsafe
Rust code. Users must ensure that resources are managed properly to avoid crashes or undefined behaviour.
Example Usage: Recording and Replaying a Stream with Aeron Archive
Below is an example of how to use AeronArchive
to set up a recording, publish messages, and replay the recorded stream.
use *;
use *;
use Duration;
use Instant;
use Cell;
use sleep;
let request_port = find_unused_udp_port.expect;
let response_port = find_unused_udp_port.expect;
let request_control_channel = &format!;
let response_control_channel = &format!;
let recording_events_channel = &format!;
assert_ne!;
let error_handler = leak;
let aeron_context = new?;
aeron_context.set_client_name?;
aeron_context.set_publication_error_frame_handler?;
aeron_context.set_error_handler?;
let aeron = new?;
aeron.start?;
println!;
let archive_context = new_with_no_credentials_supplier?;
let found_recording_signal = new;
archive_context.set_recording_signal_consumer?;
archive_context.set_idle_strategy?;
archive_context.set_error_handler?;
let connect = new?;
let archive = connect.poll_blocking?;
let channel = "aeron:ipc";
let stream_id = 10;
let subscription_id = archive.start_recording?;
println!;
let publication = aeron
.async_add_exclusive_publication?
.poll_blocking?;
let start = now;
while !found_recording_signal.get && start.elapsed.as_secs < 5
assert!;
for i in 0..11
archive.stop_recording_channel_and_stream?;
drop;
println!;
let found_recording_id = new;
let start_pos = new;
let end_pos = new;
let handler = leak;
let start = now;
while start.elapsed < from_secs
&& found_recording_id.get == -1
&& archive.list_recordings_for_uri?
<= 0
assert!;
println!;
let params = new?;
let replay_stream_id = 45;
let replay_session_id =
archive.start_replay?;
let session_id = replay_session_id as i32;
println!;
println!;
let channel_replay = format!;
println!;
println!;
let subscription = aeron
.async_add_subscription?
.poll_blocking?;
let count = new;
let poll = leak;
let start = now;
while start.elapsed < from_secs && subscription.poll? <= 0
assert!;
println!;
println!;
assert_eq!;
Ok::
Workflow Overview
- Initialize Context: Configures the archive and client contexts.
- Start Recording: Begins recording a specified channel and stream.
- Publish Messages: Sends messages to be recorded.
- Stop Recording: Ends the recording session.
- Locate Recording: Finds the recorded stream in the archive.
- Replay Setup: Sets up replay parameters and initiates replay on a new stream.
- Subscribe and Receive: Subscribes to the replayed messages, receiving and printing them as they arrive.
This example provides a practical usage of AeronArchive
for recording and replaying streams.
Building This Project
For detailed instructions on how to build rusteron, please refer to the HOW_TO_BUILD.md file.
Benchmarks
You can view the benchmarks for this project by visiting BENCHMARKS.md.
Contributing
Contributions are welcome! Please see our contributing guidelines for more information on how to get involved.
License
This project is dual-licensed under either the MIT License or Apache License 2.0. You may choose which one to use.
Links
Feel free to reach out with any questions or suggestions via GitHub Issues!