Crate rusteron_media_driver

Source
Expand description

§rusteron-media-driver

rusteron-media-driver is a module in the rusteron project that provides an interface to the Aeron Media Driver in a Rust environment. This module is crucial for managing the messaging infrastructure between producers and consumers, allowing for efficient low-latency communication.

§Overview

The rusteron-media-driver module is designed to help Rust developers interact with the Aeron Media Driver, which is responsible for managing the communication between different Aeron clients. This module provides a wrapper around the Aeron C Media Driver API and offers both standard and embedded driver options for use in different environments.

The media driver can be used to set up the messaging directory and manage data streams. The embedded media driver is particularly useful for testing purposes or for simplifying deployment scenarios where a separate media driver process is not needed.

§Usage Note

It is recommended to run the media driver using the Aeron Java or C version for production use. This crate primarily serves as a utility to start the media driver embedded within unit or integration tests.

§Installation

To use rusteron-media-driver, add it to your Cargo.toml:

dynamic lib

[dependencies]
rusteron-media-driver = "0.1"

static lib

[dependencies]
rusteron-media-driver = { version = "0.1", features= ["static"] }

static lib with precompiled c libs (mac os x only)

[dependencies]
rusteron-media-driver = { version = "0.1", features= ["static", "precompile"] }

Ensure that you have also set up the necessary Aeron C libraries required by rusteron-media-driver.

§Features

  • Media Driver Management: Start, stop, and configure an Aeron Media Driver instance.
  • Embedded Media Driver: Launch an embedded media driver directly from your code for testing purposes.

§Usage Examples

§Standard Media Driver Example

use rusteron_media_driver::{AeronDriver, AeronDriverContext};

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

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

§Embedded Media Driver Example

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>> {
    // Create and launch an embedded media driver
    let media_driver_ctx = AeronDriverContext::new()?;
    let (stop, driver_handle) = AeronDriver::launch_embedded(media_driver_ctx.clone(), false);

    // Create Aeron context and link with the embedded driver
    let ctx = AeronContext::new()?;
    ctx.set_dir(media_driver_ctx.get_dir())?;
    
    // Wait a bit for demonstration purposes
    thread::sleep(Duration::from_secs(3));

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

    Ok(())
}

§Safety Considerations

Since rusteron-media-driver relies on Aeron C bindings, it involves the use of unsafe Rust code. Users must ensure:

  • Resources are properly managed (e.g., starting and stopping drivers in a correct order).
  • Proper synchronisation when accessing shared data in a multithreaded environment.

Improper use of the media driver can lead to crashes or other undefined behaviours.

§Building This Project Instructions

For detailed instructions on how to build rusteron, please refer to the HOW_TO_BUILD.md file.

§Contributing

Contributions are more than 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.

Feel free to reach out with any questions or suggestions via GitHub Issues!

§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 AeronCError
  • extra-logging - When enabled will log when resource is created and destroyed. useful if your seeing a segfault due to a resource being closed
  • precompile - When enabled will use precompiled c code instead of requiring cmake and java to me installed

Modules§

bindings

Structs§

Addrinfo
Aeron
AeronAgentCloseFuncLogger
AeronAgentDoWorkFuncLogger
AeronAgentRunner
AeronAgentStartFuncLogger
AeronAsyncAddCounter
AeronAsyncAddExclusivePublication
AeronAsyncAddPublication
AeronAsyncAddSubscription
AeronAsyncDestination
AeronAsyncDestinationById
AeronAtomicCounter
AeronAvailableCounterLogger
AeronAvailableCounterPair
AeronAvailableImageLogger
AeronBlockHandlerLogger
AeronBlockingLinkedQueue
AeronBroadcastDescriptor
AeronBroadcastRecordDescriptor
AeronBroadcastTransmitter
AeronBufferClaim
Structure used to hold information for a try_claim function call.
AeronCError
Represents an Aeron-specific error with a code and an optional message.
AeronChannelEndpointStatusKeyLayout
AeronClient
AeronClientRegisteringResource
AeronClientTimeout
AeronClockCache
AeronCloseClientLogger
AeronCloseClientPair
AeronCnc
AeronCncConstants
AeronCncMetadata
AeronCongestionControlStrategy
AeronCongestionControlStrategyInitialWindowLengthFuncLogger
AeronCongestionControlStrategyMaxWindowLengthFuncLogger
AeronCongestionControlStrategyRttmFuncLogger
AeronCongestionControlStrategyRttmSentFuncLogger
AeronCongestionControlStrategyShouldMeasureRttFuncLogger
AeronContext
AeronControlledFragmentAssembler
AeronControlledFragmentHandlerLogger
AeronCorrelatedCommand
AeronCounter
AeronCounterCommand
AeronCounterConstants
Configuration for a counter that does not change during it’s lifetime.
AeronCounterLink
AeronCounterMetadataDescriptor
AeronCounterUpdate
AeronCounterValueDescriptor
AeronCountersManager
AeronCountersReader
AeronCountersReaderBuffers
AeronCountersReaderForeachCounterFuncLogger
AeronCountersReaderForeachMetadataFuncLogger
AeronDataHeader
AeronDataPacketDispatcher
AeronDataPacketDispatcherStreamInterest
AeronDeque
AeronDestinationByIdCommand
AeronDestinationCommand
AeronDistinctErrorLog
AeronDistinctErrorLogObservationList
AeronDistinctObservation
AeronDlLoadedLibsState
AeronDriver
AeronDriverConductor
AeronDriverConductorProxy
AeronDriverContext
AeronDriverContextBindingsClientdEntry
AeronDriverManagedResource
AeronDriverReceiver
AeronDriverReceiverImageEntry
AeronDriverReceiverPendingSetupEntry
AeronDriverReceiverProxy
AeronDriverSender
AeronDriverSenderNetworkPublicationEntry
AeronDriverSenderProxy
AeronDriverTerminationHookFuncLogger
AeronDriverTerminationValidatorFuncLogger
AeronDriverUriPublicationParams
AeronDriverUriSubscriptionParams
AeronDutyCycleStallTracker
AeronDutyCycleTracker
AeronDutyCycleTrackerMeasureAndUpdateFuncLogger
AeronDutyCycleTrackerUpdateFuncLogger
AeronEndOfLifeResource
AeronEndOfLifeResourceFreeLogger
AeronError
AeronErrorHandlerLogger
AeronErrorLogEntry
AeronErrorLogReaderFuncLogger
AeronErrorLogger
AeronErrorResponse
AeronExclusivePublication
AeronExecutorExecutionCompleteFuncLogger
AeronFeedbackDelayGeneratorState
AeronFlowControlStrategy
AeronFlowControlStrategyErrorFuncLogger
AeronFlowControlStrategyIdleFuncLogger
AeronFlowControlStrategyMaxRetransmissionLengthFuncLogger
AeronFlowControlStrategySetupFuncLogger
AeronFlowControlStrategySmFuncLogger
AeronFlowControlStrategySupplierFuncTableEntry
AeronFlowControlStrategyTriggerSendSetupFuncLogger
AeronFlowControlTaggedOptions
AeronFragmentAssembler
AeronFragmentHandlerLogger
AeronFrameHeader
AeronHeader
AeronHeaderValues
AeronHeaderValuesFrame
AeronHeartbeatTimestampKeyLayout
AeronIdleStrategy
AeronIdleStrategyFuncLogger
AeronIfaddrFuncLogger
AeronImage
AeronImageBuffersReady
AeronImageConstants
Configuration for an image that does not change during it’s lifetime.
AeronImageControlledFragmentAssembler
AeronImageFragmentAssembler
AeronImageMessage
AeronInt64CounterMap
AeronInt64CounterMapForEachFuncLogger
AeronInt64CounterMapPredicateFuncLogger
AeronInt64ToPtrHashMap
AeronInt64ToTaggedPtrEntry
AeronInt64ToTaggedPtrHashMap
AeronIovec
AeronIpcChannelParams
AeronIpcPublication
AeronIpcPublicationEntry
AeronLingerResourceEntry
AeronLinkedQueue
AeronLinkedQueueNode
AeronLocalSockaddrKeyLayout
AeronLogBuffer
AeronLogbufferMetadata
AeronLossDetector
AeronLossDetectorGap
AeronLossReporter
AeronLossReporterEntry
AeronLossReporterReadEntryFuncLogger
AeronMappedBuffer
AeronMappedFile
AeronMappedRawLog
AeronMpscConcurrentArrayQueue
AeronMpscRb
AeronNakHeader
AeronNetworkPublication
AeronNetworkPublicationEntry
AeronNewPublicationLogger
AeronNewSubscriptionLogger
AeronNotificationLogger
AeronOperationSucceeded
AeronOptionHeader
AeronParsedAddress
AeronParsedInterface
AeronPerThreadError
AeronPortManager
AeronPortManagerFreeManagedPortFuncLogger
AeronPortManagerGetManagedPortFuncLogger
AeronPosition
AeronPublication
AeronPublicationBuffersReady
AeronPublicationCommand
AeronPublicationConstants
Configuration for a publication that does not change during it’s lifetime.
AeronPublicationError
AeronPublicationErrorFrameHandlerLogger
AeronPublicationErrorValues
AeronPublicationImage
AeronPublicationImageConnection
AeronPublicationImageEntry
AeronPublicationLink
AeronRbControlledHandlerLogger
AeronRbDescriptor
AeronRbHandlerLogger
AeronRbRecordDescriptor
AeronReceiveChannelEndpoint
AeronReceiveChannelEndpointEntry
AeronReceiveDestination
AeronReceiveDestinationEntry
AeronRejectImageCommand
AeronRemoveCommand
AeronReservedValueSupplierLogger
AeronResolutionHeader
AeronResolutionHeaderIpv4
AeronResolutionHeaderIpv6
AeronResponseSetupHeader
AeronRetransmitAction
AeronRetransmitHandler
AeronRetransmitHandlerResendFuncLogger
AeronRttmHeader
AeronSendChannelEndpoint
AeronSendChannelEndpointEntry
AeronSetupHeader
AeronSpscConcurrentArrayQueue
AeronStaticCounterCommand
AeronStaticCounterResponse
AeronStatusMessageHeader
AeronStatusMessageOptionalHeader
AeronStrToPtrHashMap
AeronStrToPtrHashMapKey
AeronStreamPositionCounterKeyLayout
AeronSubscribable
AeronSubscribableListEntry
AeronSubscription
AeronSubscriptionCommand
AeronSubscriptionConstants
AeronSubscriptionLink
AeronSubscriptionReady
AeronSystemCounter
AeronSystemCounters
AeronTermGapScannerGapDetectedFuncLogger
AeronTerminateDriverCommand
AeronTetherablePosition
AeronUdpChannel
AeronUdpChannelAsyncParse
AeronUdpChannelDataPaths
AeronUdpChannelIncomingInterceptor
AeronUdpChannelInterceptorBindings
AeronUdpChannelOutgoingInterceptor
AeronUdpChannelParams
AeronUdpDestinationEntry
AeronUdpDestinationTracker
AeronUnavailableCounterLogger
AeronUnavailableCounterPair
AeronUnavailableImageLogger
AeronUri
AeronUriHostnameResolverFuncLogger
AeronUriParam
AeronUriParams
AeronUriParseCallbackLogger
AeronUriStringBuilder
AeronWildcardPortManager
AtomicWideCounterBindgenTy1
ChannelUri
Represents the Aeron URI parser and handler.
Handler
Handler
Handlers
Utility method for setting empty handlers
Ifaddrs
In6Addr
Iovec
ManagedCResource
A custom struct for managing C resources with automatic cleanup.
Mmsghdr
Msghdr
Pollfd
PthreadCondS
PthreadInternalList
PthreadMutexS
Sockaddr
SockaddrStorage
Timespec

Enums§

AeronErrorType
AeronSystemCounterType
ControlMode
Enum for control modes.
Media
Enum for media types.

Constants§

AERON_DIR_PROP_NAME
AERON_IPC_MEDIA
AERON_IPC_STREAM
AERON_UDP_MEDIA
DRIVER_TIMEOUT_MS_DEFAULT
SPY_PREFIX
TAG_PREFIX

Traits§

AeronAgentCloseFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronAgentDoWorkFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronAgentStartFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronAvailableCounterCallback
Function called by aeron_client_t to deliver notifications that a counter has been added to the driver.
AeronAvailableImageCallback
Function called by aeron_client_t to deliver notifications that an aeron_image_t was added.
AeronBlockHandlerCallback
Callback for handling a block of messages being read from a log.
AeronCloseClientCallback
Function called by aeron_client_t to deliver notifications that the client is closing.
AeronCongestionControlStrategyInitialWindowLengthFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronCongestionControlStrategyMaxWindowLengthFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronCongestionControlStrategyRttmFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronCongestionControlStrategyRttmSentFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronCongestionControlStrategyShouldMeasureRttFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronControlledFragmentHandlerCallback
Callback for handling fragments of data being read from a log.
AeronCountersReaderForeachCounterFuncCallback
Function called by aeron_counters_reader_foreach_counter for each counter in the aeron_counters_reader_t.
AeronCountersReaderForeachMetadataFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronDriverTerminationHookFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronDriverTerminationValidatorFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronDutyCycleTrackerMeasureAndUpdateFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronDutyCycleTrackerUpdateFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronEndOfLifeResourceFreeCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronErrorHandlerCallback
The error handler to be called when an error occurs.
AeronErrorLogReaderFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronExecutorExecutionCompleteFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronFlowControlStrategyErrorFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronFlowControlStrategyIdleFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronFlowControlStrategyMaxRetransmissionLengthFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronFlowControlStrategySetupFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronFlowControlStrategySmFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronFlowControlStrategyTriggerSendSetupFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronFragmentHandlerCallback
Callback for handling fragments of data being read from a log.
AeronIdleStrategyFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronIfaddrFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronInt64CounterMapForEachFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronInt64CounterMapPredicateFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronLossReporterReadEntryFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronNewPublicationCallback
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.
AeronNewSubscriptionCallback
Function called by aeron_client_t to deliver notification that the media driver has added an aeron_subscription_t successfully.
AeronNotificationCallback
Generalised notification callback.
AeronPortManagerFreeManagedPortFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronPortManagerGetManagedPortFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronPublicationErrorFrameHandlerCallback
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.
AeronRbControlledHandlerCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronRbHandlerCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronReservedValueSupplierCallback
Function called when filling in the reserved value field of a message.
AeronRetransmitHandlerResendFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronTermGapScannerGapDetectedFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronUnavailableCounterCallback
Function called by aeron_client_t to deliver notifications that a counter has been removed from the driver.
AeronUnavailableImageCallback
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.
AeronUriHostnameResolverFuncCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)
AeronUriParseCallbackCallback
(note you must copy any arguments that you use afterwards even those with static lifetimes)

Functions§

find_unused_udp_port
is_udp_port_available