From fa68fb62d3cb52d8a3c581f6213b8339e2a431a5 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Sat, 14 Nov 2015 14:13:32 -0800 Subject: [PATCH] Change event type to string --- api/tasks.go | 13 +++++-------- nomad/structs/structs.go | 15 ++++++--------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/api/tasks.go b/api/tasks.go index 4a1305461..548906ae2 100644 --- a/api/tasks.go +++ b/api/tasks.go @@ -118,20 +118,17 @@ type TaskState struct { Events []*TaskEvent } -// TaskEventType is the set of events that effect the state of a task. -type TaskEventType int - const ( - TaskDriverFailure TaskEventType = iota - TaskStarted - TaskTerminated - TaskKilled + TaskDriverFailure = "Driver Failure" + TaskStarted = "Started" + TaskTerminated = "Terminated" + TaskKilled = "Killed" ) // TaskEvent is an event that effects the state of a task and contains meta-data // appropriate to the events type. type TaskEvent struct { - Type TaskEventType + Type string Time int64 DriverError error ExitCode int diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index 3cc7fdbac..7c040e9d8 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -1070,29 +1070,26 @@ type TaskState struct { Events []*TaskEvent } -// TaskEventType is the set of events that effect the state of a task. -type TaskEventType int - const ( // A Driver failure indicates that the task could not be started due to a // failure in the driver. - TaskDriverFailure TaskEventType = iota + TaskDriverFailure = "Driver Failure" // Task Started signals that the task was started and its timestamp can be // used to determine the running length of the task. - TaskStarted + TaskStarted = "Started" // Task terminated indicates that the task was started and exited. - TaskTerminated + TaskTerminated = "Terminated" // Task Killed indicates a user has killed the task. - TaskKilled + TaskKilled = "Killed" ) // TaskEvent is an event that effects the state of a task and contains meta-data // appropriate to the events type. type TaskEvent struct { - Type TaskEventType + Type string Time int64 // Unix Nanosecond timestamp // Driver Failure fields. @@ -1107,7 +1104,7 @@ type TaskEvent struct { KillError string // Error killing the task. } -func NewTaskEvent(event TaskEventType) *TaskEvent { +func NewTaskEvent(event string) *TaskEvent { return &TaskEvent{ Type: event, Time: time.Now().UnixNano(),