Add pause resume to task
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
e2db2892ec
commit
1de25c09e3
@ -85,10 +85,12 @@ func (c *Container) NewTask(ctx context.Context, ioCreate IOCreation) (*Task, er
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &Task{
|
t := &Task{
|
||||||
client: c.client,
|
client: c.client,
|
||||||
io: i,
|
io: i,
|
||||||
containerID: response.ContainerID,
|
containerID: response.ContainerID,
|
||||||
pid: response.Pid,
|
pid: response.Pid,
|
||||||
}, nil
|
}
|
||||||
|
c.task = t
|
||||||
|
return t, nil
|
||||||
}
|
}
|
||||||
|
24
task.go
24
task.go
@ -189,6 +189,30 @@ func (t *Task) Kill(ctx context.Context, s syscall.Signal) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *Task) Pause(ctx context.Context) error {
|
||||||
|
_, err := t.client.tasks().Pause(ctx, &execution.PauseRequest{
|
||||||
|
ContainerID: t.containerID,
|
||||||
|
})
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *Task) Resume(ctx context.Context) error {
|
||||||
|
_, err := t.client.tasks().Resume(ctx, &execution.ResumeRequest{
|
||||||
|
ContainerID: t.containerID,
|
||||||
|
})
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *Task) Status(ctx context.Context) (string, error) {
|
||||||
|
r, err := t.client.tasks().Info(ctx, &execution.InfoRequest{
|
||||||
|
ContainerID: t.containerID,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return r.Task.Status.String(), nil
|
||||||
|
}
|
||||||
|
|
||||||
// Wait is a blocking call that will wait for the task to exit and return the exit status
|
// Wait is a blocking call that will wait for the task to exit and return the exit status
|
||||||
func (t *Task) Wait(ctx context.Context) (uint32, error) {
|
func (t *Task) Wait(ctx context.Context) (uint32, error) {
|
||||||
events, err := t.client.tasks().Events(ctx, &execution.EventsRequest{})
|
events, err := t.client.tasks().Events(ctx, &execution.EventsRequest{})
|
||||||
|
Loading…
Reference in New Issue
Block a user