bpm_engine_worker_sdk/
handler.rs1use async_trait::async_trait;
4
5use crate::types::{ExternalTask, TaskResult};
6
7#[derive(Debug, Clone)]
9pub struct TaskContext {
10 #[allow(dead_code)]
11 pub(crate) worker_id: String,
12 #[allow(dead_code)]
13 pub(crate) task_id: String,
14}
15
16impl TaskContext {
17 pub fn new(worker_id: String, task_id: String) -> Self {
18 Self { worker_id, task_id }
19 }
20}
21
22#[async_trait]
24pub trait TaskHandler: Send + Sync {
25 fn task_type(&self) -> &str;
26
27 async fn handle(&self, task: ExternalTask, ctx: TaskContext) -> TaskResult;
28}