pub struct SourceRuntimeContext {
pub source_id: String,
pub status_tx: ComponentEventSender,
pub state_store: Option<Arc<dyn StateStoreProvider>>,
}Expand description
Context provided to Source plugins during initialization.
Contains Arc<T> instances for all drasi-lib provided services.
DrasiLib constructs this context when a source is added via add_source().
§Available Services
source_id: The unique identifier for this source instancestatus_tx: Channel for reporting component status/lifecycle eventsstate_store: Optional persistent state storage (if configured)
§Clone
This struct implements Clone and all fields use Arc internally,
making cloning cheap (just reference count increments).
Fields§
§source_id: StringUnique identifier for this source instance
status_tx: ComponentEventSenderChannel for reporting component status/lifecycle events.
Use this to send status updates (Starting, Running, Stopped, Error) back to DrasiLib for monitoring and lifecycle management.
state_store: Option<Arc<dyn StateStoreProvider>>Optional persistent state storage.
This is Some if a state store provider was configured on DrasiLib,
otherwise None. Sources can use this to persist state across restarts.
Implementations§
Source§impl SourceRuntimeContext
impl SourceRuntimeContext
Sourcepub fn new(
source_id: impl Into<String>,
status_tx: ComponentEventSender,
state_store: Option<Arc<dyn StateStoreProvider>>,
) -> Self
pub fn new( source_id: impl Into<String>, status_tx: ComponentEventSender, state_store: Option<Arc<dyn StateStoreProvider>>, ) -> Self
Create a new source runtime context.
This is typically called by SourceManager when adding a source to DrasiLib.
Plugin developers do not need to call this directly.
§Arguments
source_id- The unique identifier for this sourcestatus_tx- Channel for reporting component status/lifecycle eventsstate_store- Optional persistent state storage
Sourcepub fn status_tx(&self) -> &ComponentEventSender
pub fn status_tx(&self) -> &ComponentEventSender
Get a reference to the status channel.
Use this to send component status updates (Starting, Running, Stopped, Error) back to DrasiLib.
Sourcepub fn state_store(&self) -> Option<&Arc<dyn StateStoreProvider>>
pub fn state_store(&self) -> Option<&Arc<dyn StateStoreProvider>>
Get a reference to the state store if configured.
Returns Some(&Arc<dyn StateStoreProvider>) if a state store was configured,
otherwise None.
Trait Implementations§
Source§impl Clone for SourceRuntimeContext
impl Clone for SourceRuntimeContext
Source§fn clone(&self) -> SourceRuntimeContext
fn clone(&self) -> SourceRuntimeContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more