pub struct ReactionRuntimeContext {
pub reaction_id: String,
pub status_tx: ComponentEventSender,
pub state_store: Option<Arc<dyn StateStoreProvider>>,
pub query_provider: Arc<dyn QueryProvider>,
}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
reaction_id: The unique identifier for this reaction instancestatus_tx: Channel for reporting component status/lifecycle eventsstate_store: Optional persistent state storage (if configured)query_provider: Access to query instances for subscription
§Clone
This struct implements Clone and all fields use Arc internally,
making cloning cheap (just reference count increments).
Fields§
§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.
query_provider: Arc<dyn QueryProvider>Access to query instances for subscription.
Reactions use this to get query instances and subscribe to their results. This is always available (not optional) since reactions require queries.
Implementations§
Source§impl ReactionRuntimeContext
impl ReactionRuntimeContext
Sourcepub fn new(
reaction_id: impl Into<String>,
status_tx: ComponentEventSender,
state_store: Option<Arc<dyn StateStoreProvider>>,
query_provider: Arc<dyn QueryProvider>,
) -> Self
pub fn new( reaction_id: impl Into<String>, status_tx: ComponentEventSender, state_store: Option<Arc<dyn StateStoreProvider>>, query_provider: Arc<dyn QueryProvider>, ) -> 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
reaction_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 reaction_id(&self) -> &str
pub fn reaction_id(&self) -> &str
Get the reaction’s unique identifier.
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.
Sourcepub fn query_provider(&self) -> &Arc<dyn QueryProvider>
pub fn query_provider(&self) -> &Arc<dyn QueryProvider>
Get a reference to the query provider.
Use this to get query instances and subscribe to their results.
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