-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.go
More file actions
38 lines (32 loc) · 812 Bytes
/
models.go
File metadata and controls
38 lines (32 loc) · 812 Bytes
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
package taskflow
import (
"encoding/json"
"time"
)
// JobStatus enumerates the possible states of a job.
type JobStatus string
const (
JobPending JobStatus = "PENDING"
JobInProgress JobStatus = "IN_PROGRESS"
JobCompleted JobStatus = "COMPLETED"
JobFailed JobStatus = "FAILED"
)
// Operation is a type for your job "name" or "action" (e.g., "ADD_CUSTOMER").
type Operation string
// JobRecord corresponds to one row in the jobs table.
type JobRecord struct {
ID uint64
Operation Operation
Status JobStatus
payload []byte
Output any
LockedBy *string
LockedUntil *time.Time
RetryCount uint
AvailableAt *time.Time
CreatedAt time.Time
UpdatedAt time.Time
}
func (jr *JobRecord) GetPayload(input any) error {
return json.Unmarshal(jr.payload, &input)
}