-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
tasks.go
33 lines (27 loc) · 965 Bytes
/
tasks.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
// Copyright 2015, Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package automation
import (
automationpb "github.com/youtube/vitess/go/vt/proto/automation"
)
// Helper functions for "Task" protobuf message.
// MarkTaskSucceeded marks the task as done.
func MarkTaskSucceeded(t *automationpb.Task, output string) {
t.State = automationpb.TaskState_DONE
t.Output = output
}
// MarkTaskFailed marks the task as failed.
func MarkTaskFailed(t *automationpb.Task, output string, err error) {
t.State = automationpb.TaskState_DONE
t.Output = output
t.Error = err.Error()
}
// NewTask creates a new task protobuf message for "taskName" with "parameters".
func NewTask(taskName string, parameters map[string]string) *automationpb.Task {
return &automationpb.Task{
State: automationpb.TaskState_NOT_STARTED,
Name: taskName,
Parameters: parameters,
}
}