pub trait ExecutableItem: Send + 'static {
// Required method
fn execute(&mut self, ctx: &mut Context<'_>) -> ExecuteResult;
// Provided methods
fn declare_triggers(
&mut self,
d: &mut TriggerDeclarer<'_>,
) -> Result<(), ExecutorError> { ... }
fn task_id(&self) -> Option<&str> { ... }
fn app_id(&self) -> Option<u32> { ... }
fn app_instance_id(&self) -> Option<u32> { ... }
}Expand description
Trait implemented by every unit of work the executor schedules.
Implementors are moved into the executor and dispatched to pool workers.
Send + 'static is required; Sync is not — the executor guarantees
at most one thread at a time invokes execute on a given item.
Required Methods§
Sourcefn execute(&mut self, ctx: &mut Context<'_>) -> ExecuteResult
fn execute(&mut self, ctx: &mut Context<'_>) -> ExecuteResult
Called by the executor when any declared trigger fires.
Provided Methods§
Sourcefn declare_triggers(
&mut self,
d: &mut TriggerDeclarer<'_>,
) -> Result<(), ExecutorError>
fn declare_triggers( &mut self, d: &mut TriggerDeclarer<'_>, ) -> Result<(), ExecutorError>
Called once when the item is added to an executor. The implementor
registers its trigger handles via the TriggerDeclarer.
Sourcefn task_id(&self) -> Option<&str>
fn task_id(&self) -> Option<&str>
Optional human-readable id used for monitor/observer correlation.
None means “use the auto-assigned id”.
Sourcefn app_id(&self) -> Option<u32>
fn app_id(&self) -> Option<u32>
Optional application id; Some(_) enables Observer per-app callbacks.
Sourcefn app_instance_id(&self) -> Option<u32>
fn app_instance_id(&self) -> Option<u32>
Optional application instance id.
Trait Implementations§
Source§impl ExecutableItem for Box<dyn ExecutableItem>
Allows Vec<Box<dyn ExecutableItem>> to be passed directly to
crate::Executor::add_chain without a secondary wrapper.
impl ExecutableItem for Box<dyn ExecutableItem>
Allows Vec<Box<dyn ExecutableItem>> to be passed directly to
crate::Executor::add_chain without a secondary wrapper.
Source§fn declare_triggers(
&mut self,
d: &mut TriggerDeclarer<'_>,
) -> Result<(), ExecutorError>
fn declare_triggers( &mut self, d: &mut TriggerDeclarer<'_>, ) -> Result<(), ExecutorError>
TriggerDeclarer.Source§fn execute(&mut self, ctx: &mut Context<'_>) -> ExecuteResult
fn execute(&mut self, ctx: &mut Context<'_>) -> ExecuteResult
Source§fn task_id(&self) -> Option<&str>
fn task_id(&self) -> Option<&str>
None means “use the auto-assigned id”.Source§fn app_id(&self) -> Option<u32>
fn app_id(&self) -> Option<u32>
Some(_) enables Observer per-app callbacks.Source§fn app_instance_id(&self) -> Option<u32>
fn app_instance_id(&self) -> Option<u32>
Implementations on Foreign Types§
Source§impl ExecutableItem for Box<dyn ExecutableItem>
Allows Vec<Box<dyn ExecutableItem>> to be passed directly to
crate::Executor::add_chain without a secondary wrapper.
impl ExecutableItem for Box<dyn ExecutableItem>
Allows Vec<Box<dyn ExecutableItem>> to be passed directly to
crate::Executor::add_chain without a secondary wrapper.