Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTerminatedError ¶
IsTerminatedError checks whether task enters a terminated state, which include finished, canceled
Types ¶
type Runner ¶
type Runner[T Task] struct { // contains filtered or unexported fields }
Runner runs a Task.
type Task ¶
type Task interface {
// Init is called before entering the loop calling Poll.
Init(ctx context.Context) error
// Poll should be called periodically until an error is returned.
Poll(ctx context.Context) error
// NotifyExit does necessary bookkeeping job for exiting,
// such as notifying a master.
// errIn describes the reason for exiting.
NotifyExit(ctx context.Context, errIn error) error
// Close does necessary clean up.
// TODO `ctx` is for compatibility, remove it.
Close(ctx context.Context) error
// Stop is called when a task is canceled
Stop(ctx context.Context) error
// ID returns an identifier for the Task.
ID() string
}
Task defines the common methods used to drive both workers and masters. It will replace the current `Worker` interface in further refactors.
Click to show internal directories.
Click to hide internal directories.