Skip to main content

coil_core/manifest/
jobs.rs

1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2pub enum JobTriggerKind {
3    Scheduled,
4    DomainEvent,
5    Operator,
6    Webhook,
7    InlineFollowup,
8}
9
10#[derive(Debug, Clone, PartialEq, Eq)]
11pub struct JobContract {
12    pub name: String,
13    pub trigger: JobTriggerKind,
14    pub idempotent: bool,
15    pub description: String,
16}
17
18impl JobContract {
19    pub fn new(
20        name: impl Into<String>,
21        trigger: JobTriggerKind,
22        idempotent: bool,
23        description: impl Into<String>,
24    ) -> Self {
25        Self {
26            name: name.into(),
27            trigger,
28            idempotent,
29            description: description.into(),
30        }
31    }
32}
33
34#[derive(Debug, Clone, PartialEq, Eq)]
35pub struct EventSubscription {
36    pub event: String,
37    pub job: Option<String>,
38    pub description: String,
39}
40
41impl EventSubscription {
42    pub fn new(
43        event: impl Into<String>,
44        job: Option<impl Into<String>>,
45        description: impl Into<String>,
46    ) -> Self {
47        Self {
48            event: event.into(),
49            job: job.map(Into::into),
50            description: description.into(),
51        }
52    }
53}