added snippet upload
This commit is contained in:
parent
349afa60e1
commit
861ca4edf7
7 changed files with 281 additions and 81 deletions
7
task.go
7
task.go
|
|
@ -16,8 +16,12 @@ const (
|
|||
TaskExitStatusOK = "OK"
|
||||
TaskStatusRunning = "running"
|
||||
TaskStatusStopped = "stopped"
|
||||
|
||||
DummyTaskID = "dummy"
|
||||
)
|
||||
|
||||
var DummyTask = Task{ID: DummyTaskID}
|
||||
|
||||
type Task struct {
|
||||
ID string `json:"upid"`
|
||||
Type string `json:"type"`
|
||||
|
|
@ -63,6 +67,9 @@ func (c *TaskClient) Get(ctx context.Context, taskid string) (t *Task, err error
|
|||
type OnTaskChange func(t *Task)
|
||||
|
||||
func (c *TaskClient) Wait(ctx context.Context, t *Task, f OnTaskChange) error {
|
||||
if t.ID == DummyTaskID {
|
||||
return nil
|
||||
}
|
||||
if f != nil && t.Status != "" {
|
||||
f(t)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue