Skip to main content

TaskHandler

Trait TaskHandler 

Source
pub trait TaskHandler: Send + Sync {
    // Required methods
    fn task_type(&self) -> &str;
    fn execute(&self, ctx: &TaskContext, payload: &[u8]) -> Result<TaskEvent>;

    // Provided method
    fn validate(&self, _payload: &[u8]) -> Result<()> { ... }
}
Expand description

Trait implemented by task handlers.

Task handlers execute scheduled tasks and produce events that are written to the canonical event log.

Required Methods§

Source

fn task_type(&self) -> &str

Returns the task type this handler processes.

Source

fn execute(&self, ctx: &TaskContext, payload: &[u8]) -> Result<TaskEvent>

Execute the task with the given context and payload.

Returns a TaskEvent that will be written to the canonical log. The event will then be processed by registered event handlers.

Provided Methods§

Source

fn validate(&self, _payload: &[u8]) -> Result<()>

Validate the task payload (optional).

Called when scheduling a task to ensure the payload is valid. Default implementation always succeeds.

Implementors§