-
Notifications
You must be signed in to change notification settings - Fork 136
/
model.go
87 lines (78 loc) · 2.68 KB
/
model.go
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package model
import (
"time"
"github.com/apache/pulsar-client-go/pulsar"
)
// CreateJobInstruction is an instruction to insert a new row into the jobs table
type CreateJobInstruction struct {
JobId string
Queue string
Owner string
JobSet string
Cpu int64
Memory int64
EphemeralStorage int64
Gpu int64
Priority int64
Submitted time.Time
State int32
LastTransitionTime time.Time
LastTransitionTimeSeconds int64
JobProto []byte
PriorityClass *string
}
// UpdateJobInstruction is an instruction to update an existing row in the jobs table
type UpdateJobInstruction struct {
JobId string
Priority *int64
State *int32
Cancelled *time.Time
CancelReason *string
LastTransitionTime *time.Time
LastTransitionTimeSeconds *int64
Duplicate *bool
LatestRunId *string
}
// CreateUserAnnotationInstruction is an instruction to create a new entry in the UserAnnotationInstruction table
type CreateUserAnnotationInstruction struct {
JobId string
Key string
Value string
Queue string
Jobset string
}
// CreateJobRunInstruction is an instruction to update an existing row in the jobRuns table
type CreateJobRunInstruction struct {
RunId string
JobId string
Cluster string
Node *string
Leased *time.Time
Pending *time.Time
JobRunState int32
}
// UpdateJobRunInstruction is an instruction to update an existing row in the job runs table
type UpdateJobRunInstruction struct {
RunId string
Node *string
Pending *time.Time
Started *time.Time
Finished *time.Time
JobRunState *int32
Error []byte
ExitCode *int32
}
// InstructionSet represents a set of instructions to apply to the database. Each type of instruction is stored in its
// own ordered list representign the order it was received. We also store the original message ids corresponding to
// these instructions so that when they are saved to the database, we can ACK the corresponding messages.
type InstructionSet struct {
JobsToCreate []*CreateJobInstruction
JobsToUpdate []*UpdateJobInstruction
JobRunsToCreate []*CreateJobRunInstruction
JobRunsToUpdate []*UpdateJobRunInstruction
UserAnnotationsToCreate []*CreateUserAnnotationInstruction
MessageIds []pulsar.MessageID
}
func (i *InstructionSet) GetMessageIDs() []pulsar.MessageID {
return i.MessageIds
}