-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatus.go
More file actions
56 lines (44 loc) · 1.58 KB
/
status.go
File metadata and controls
56 lines (44 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package durex
// Status represents the execution state of a command instance.
type Status string
const (
// StatusPending indicates the command is waiting to be executed.
StatusPending Status = "PENDING"
// StatusStarted indicates the command is currently executing.
StatusStarted Status = "STARTED"
// StatusCompleted indicates the command finished successfully.
StatusCompleted Status = "COMPLETED"
// StatusFailed indicates the command failed after exhausting retries.
StatusFailed Status = "FAILED"
// StatusExpired indicates the command's deadline passed before execution.
StatusExpired Status = "EXPIRED"
// StatusRepeating indicates the command is scheduled to repeat.
StatusRepeating Status = "REPEATING"
// StatusCancelled indicates the command was cancelled before completion.
StatusCancelled Status = "CANCELLED"
// StatusDeadLetter indicates the command failed permanently and was moved to DLQ.
// Commands in DLQ can be inspected and replayed manually.
StatusDeadLetter Status = "DEAD_LETTER"
)
// IsTerminal returns true if the status represents a final state.
func (s Status) IsTerminal() bool {
switch s {
case StatusCompleted, StatusFailed, StatusExpired, StatusCancelled, StatusDeadLetter:
return true
default:
return false
}
}
// IsActive returns true if the status represents an active/running state.
func (s Status) IsActive() bool {
switch s {
case StatusPending, StatusStarted, StatusRepeating:
return true
default:
return false
}
}
// String returns the string representation of the status.
func (s Status) String() string {
return string(s)
}