Skip to main content

sova_tasks/
events.rs

1//! Domain events emitted on the app [`EventBus`](sova_core::EventBus).
2
3use sova_core::Event;
4
5/// Fired after a task is successfully enqueued.
6#[derive(Debug, Clone)]
7pub struct TaskDispatched {
8    pub id: String,
9    pub name: String,
10    pub queue: String,
11}
12
13impl Event for TaskDispatched {
14    fn name(&self) -> &'static str {
15        "tasks.dispatched"
16    }
17}
18
19/// Fired when a worker marks a task as terminal failure (no more retries).
20#[derive(Debug, Clone)]
21pub struct TaskFailed {
22    pub id: String,
23    pub name: String,
24    pub attempts: u32,
25}
26
27impl Event for TaskFailed {
28    fn name(&self) -> &'static str {
29        "tasks.failed"
30    }
31}