-
Notifications
You must be signed in to change notification settings - Fork 132
/
jobid.go
54 lines (51 loc) · 1.68 KB
/
jobid.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
package armadaevents
import (
"github.com/pkg/errors"
"github.com/armadaproject/armada/internal/common/armadaerrors"
)
func JobIdFromEvent(event *EventSequence_Event) (*Uuid, error) {
switch e := event.Event.(type) {
case *EventSequence_Event_SubmitJob:
return e.SubmitJob.JobId, nil
case *EventSequence_Event_ReprioritiseJob:
return e.ReprioritiseJob.JobId, nil
case *EventSequence_Event_ReprioritisedJob:
return e.ReprioritisedJob.JobId, nil
case *EventSequence_Event_CancelJob:
return e.CancelJob.JobId, nil
case *EventSequence_Event_CancelledJob:
return e.CancelledJob.JobId, nil
case *EventSequence_Event_JobSucceeded:
return e.JobSucceeded.JobId, nil
case *EventSequence_Event_JobRunSucceeded:
return e.JobRunSucceeded.JobId, nil
case *EventSequence_Event_JobRunLeased:
return e.JobRunLeased.JobId, nil
case *EventSequence_Event_JobRunAssigned:
return e.JobRunAssigned.JobId, nil
case *EventSequence_Event_JobRunRunning:
return e.JobRunRunning.JobId, nil
case *EventSequence_Event_JobErrors:
return e.JobErrors.JobId, nil
case *EventSequence_Event_JobRunErrors:
return e.JobRunErrors.JobId, nil
case *EventSequence_Event_JobDuplicateDetected:
return e.JobDuplicateDetected.NewJobId, nil
case *EventSequence_Event_StandaloneIngressInfo:
return e.StandaloneIngressInfo.JobId, nil
case *EventSequence_Event_JobRunPreempted:
return e.JobRunPreempted.PreemptedJobId, nil
case *EventSequence_Event_JobRequeued:
return e.JobRequeued.JobId, nil
default:
err := errors.WithStack(&armadaerrors.ErrInvalidArgument{
Name: "event.Event",
Value: e,
Message: "event doesn't contain a jobId",
})
return &Uuid{
High64: 0,
Low64: 0,
}, err
}
}