pub struct SourceRuntimeContext {
pub instance_id: String,
pub source_id: String,
pub state_store: Option<Arc<dyn StateStoreProvider>>,
pub update_tx: ComponentUpdateSender,
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 instancestate_store: Optional persistent state storage (if configured)update_tx: mpsc sender for fire-and-forget status updates to the component graph
§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
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.
update_tx: ComponentUpdateSendermpsc sender for fire-and-forget component status updates.
Status changes sent here are applied to the component graph by the graph update loop, which emits broadcast events to all subscribers.
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>,
state_store: Option<Arc<dyn StateStoreProvider>>,
update_tx: ComponentUpdateSender,
identity_provider: Option<Arc<dyn IdentityProvider>>,
) -> Self
pub fn new( instance_id: impl Into<String>, source_id: impl Into<String>, state_store: Option<Arc<dyn StateStoreProvider>>, update_tx: ComponentUpdateSender, identity_provider: Option<Arc<dyn IdentityProvider>>, ) -> 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 sourcestate_store- Optional persistent state storageupdate_tx- mpsc sender for status updates to the component graphidentity_provider- Optional identity provider for credential injection
Sourcepub fn instance_id(&self) -> &str
pub fn instance_id(&self) -> &str
Get the DrasiLib instance ID.
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