mirror of
https://github.com/kemko/nomad.git
synced 2026-01-03 17:05:43 +03:00
30 lines
698 B
Go
30 lines
698 B
Go
package drivers
|
|
|
|
import (
|
|
"github.com/hashicorp/nomad/plugins/base"
|
|
)
|
|
|
|
// TaskHandle is the state shared between a driver and the client.
|
|
// It is returned to the client after starting the task and used
|
|
// for recovery of tasks during a driver restart.
|
|
type TaskHandle struct {
|
|
Driver string
|
|
Config *TaskConfig
|
|
State TaskState
|
|
driverState []byte
|
|
}
|
|
|
|
func NewTaskHandle(driver string) *TaskHandle {
|
|
return &TaskHandle{Driver: driver}
|
|
}
|
|
|
|
func (h *TaskHandle) SetDriverState(v interface{}) error {
|
|
h.driverState = []byte{}
|
|
return base.MsgPackEncode(&h.driverState, v)
|
|
}
|
|
|
|
func (h *TaskHandle) GetDriverState(v interface{}) error {
|
|
return base.MsgPackDecode(h.driverState, v)
|
|
|
|
}
|