Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller is responsible for submitting tasks, noticing responding when task status changes.
TODO(damnever): API to notify task status changes.
- we can simply watch the key: /task-coordinator/<version>/status/kinds/<task-kind>/names/<task-name>
func NewController ¶
func NewController(ctx context.Context, cli state.Repository) *Controller
NewController creates a new controller.
func (*Controller) Submit ¶
func (c *Controller) Submit(kind Kind, name string, params []ControllerTaskParam) error
Submit submits a task with params and node ids, a readable name with context information is recommended.
type ControllerTaskParam ¶
ControllerTaskParam is the param for tasks, the node id is the unique id for node.
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor executes tasks on node.
func NewExecutor ¶
NewExecutor creates a new Executor, the keypfx must be the same as Controller's.
type Processor ¶
type Processor interface { Kind() Kind RetryCount() int RetryBackOff() time.Duration Concurrency() int Process(ctx context.Context, task Task) error }
Processor is responsible for process actual tasks. The caller must ensure Process func is goroutine safe if it changes the shared state.
type Task ¶
type Task struct { Kind Kind `json:"kind"` Name string `json:"name"` Executor string `json:"executor"` Params json.RawMessage `json:"params"` State State `json:"state"` ErrMsg string `json:"err_msg,omitempty"` }
Task is the actual task with parameters and status.
func (Task) UnsafeMarshal ¶
UnsafeMarshal marshals itself by JSON encoder, it will panic if error occurs.
func (*Task) UnsafeUnmarshal ¶
UnsafeUnmarshal unmarshals itself by JSON decoder, it will panic if error occurs.