pub struct ReactionRuntimeContext {
pub instance_id: String,
pub reaction_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 Reaction plugins during initialization.
Contains Arc<T> instances for all drasi-lib provided services.
DrasiLib constructs this context when a reaction is added via add_reaction().
§Available Services
instance_id: The DrasiLib instance ID (for log routing isolation)reaction_id: The unique identifier for this reaction 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)
reaction_id: StringUnique identifier for this reaction 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. Reactions 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.
Reactions can use this to obtain authentication credentials (passwords, tokens,
certificates) for connecting to external systems.
Implementations§
Source§impl ReactionRuntimeContext
impl ReactionRuntimeContext
Sourcepub fn new(
instance_id: impl Into<String>,
reaction_id: impl Into<String>,
status_tx: ComponentEventSender,
state_store: Option<Arc<dyn StateStoreProvider>>,
) -> Self
pub fn new( instance_id: impl Into<String>, reaction_id: impl Into<String>, status_tx: ComponentEventSender, state_store: Option<Arc<dyn StateStoreProvider>>, ) -> Self
Create a new reaction runtime context.
This is typically called by ReactionManager when adding a reaction to DrasiLib.
Plugin developers do not need to call this directly.
§Arguments
instance_id- The DrasiLib instance IDreaction_id- The unique identifier for this reactionstatus_tx- Channel for reporting component status/lifecycle eventsstate_store- Optional persistent state storagequery_provider- Access to query instances for subscription
Sourcepub fn instance_id(&self) -> &str
pub fn instance_id(&self) -> &str
Get the DrasiLib instance ID.
Sourcepub fn reaction_id(&self) -> &str
pub fn reaction_id(&self) -> &str
Get the reaction’s unique identifier.
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.
Trait Implementations§
Source§impl Clone for ReactionRuntimeContext
impl Clone for ReactionRuntimeContext
Source§fn clone(&self) -> ReactionRuntimeContext
fn clone(&self) -> ReactionRuntimeContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more