pub struct SourceRuntimeContext {
pub instance_id: String,
pub source_id: String,
pub status_tx: ComponentEventSender,
pub state_store: Option<Arc<dyn StateStoreProvider>>,
pub identity_provider: Option<Arc<dyn IdentityProvider>>,
}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
instance_id: The DrasiLib instance ID (for log routing isolation)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§
§instance_id: StringDrasiLib instance ID (for log routing isolation)
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.
identity_provider: Option<Arc<dyn IdentityProvider>>Optional identity provider for credential injection.
This is Some if the host has configured an identity provider for this component.
Sources can use this to obtain authentication credentials (passwords, tokens,
certificates) for connecting to external systems.
Implementations§
Source§impl SourceRuntimeContext
impl SourceRuntimeContext
Sourcepub fn new(
instance_id: impl Into<String>,
source_id: impl Into<String>,
status_tx: ComponentEventSender,
state_store: Option<Arc<dyn StateStoreProvider>>,
) -> Self
pub fn new( instance_id: impl Into<String>, 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
instance_id- The DrasiLib instance IDsource_id- The unique identifier for this sourcestatus_tx- Channel for reporting component status/lifecycle eventsstate_store- Optional persistent state storage
Sourcepub fn instance_id(&self) -> &str
pub fn instance_id(&self) -> &str
Get the DrasiLib instance ID.
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