1#![doc = "Core types and state transitions for pgtask."]
2
3mod identifier;
4mod retry;
5mod schedule;
6mod task;
7
8pub use identifier::{
9 HandlerVersion, LeaseToken, NameError, QueueName, ScheduleId, ScheduleName, SignalName, StepName, TaskId, TaskName,
10 WorkerId,
11};
12pub use retry::RetryPolicy;
13pub use schedule::{Materialization, MisfirePolicy, Schedule, ScheduleConfig, ScheduleDefinition, ScheduleError};
14pub use task::{
15 Checkpoint, EnqueueRequest, EnqueueResult, LeaseRenewal, Queue, QueueConfig, Signal, Task, TaskResult, TaskState,
16 WorkerRecord,
17};
18
19pub const STORAGE_PROTOCOL_MIN_VERSION: u32 = 1;
21
22pub const STORAGE_PROTOCOL_MAX_VERSION: u32 = 1;
24
25pub const STORAGE_PROTOCOL_VERSION: u32 = STORAGE_PROTOCOL_MAX_VERSION;
27
28#[derive(Clone, Copy, Debug, PartialEq, Eq)]
29pub struct StorageProtocolRange {
30 pub minimum: u32,
31 pub maximum: u32,
32}
33
34impl StorageProtocolRange {
35 pub const fn new(minimum: u32, maximum: u32) -> Option<Self> {
36 if minimum == 0 || maximum < minimum {
37 return None;
38 }
39 Some(Self { minimum, maximum })
40 }
41
42 pub const fn overlaps(self, other: Self) -> bool {
43 self.minimum <= other.maximum && other.minimum <= self.maximum
44 }
45}
46
47pub const STORAGE_PROTOCOL_RANGE: StorageProtocolRange = StorageProtocolRange {
48 minimum: STORAGE_PROTOCOL_MIN_VERSION,
49 maximum: STORAGE_PROTOCOL_MAX_VERSION,
50};