Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyMask(task *Task)
- func Encode(task *Task) ([]byte, error)
- func IsTerminal(state TaskState) bool
- func NotifyCallback(task *Task)
- type CallbackData
- type DefaultTaskDB
- func (db *DefaultTaskDB) Clean() error
- func (db *DefaultTaskDB) Close()
- func (db *DefaultTaskDB) DeleteTask(id string) error
- func (db *DefaultTaskDB) ListNonTerminalTasks() ([]*Task, error)
- func (db *DefaultTaskDB) PutTask(task *Task) error
- func (db *DefaultTaskDB) ReadTask(id string) (Task, error)
- func (db *DefaultTaskDB) ReadUnmaskedTask(id string) (Task, error)
- type Port
- type Request
- type Scheduler
- type SlaveConstraint
- type Status
- type Task
- func (task *Task) CurrentStatus() TaskState
- func (task *Task) IsRunning() bool
- func (task *Task) IsTerminated() bool
- func (task *Task) IsTerminating() bool
- func (task *Task) IsWaiting() bool
- func (task *Task) LastUpdated() time.Time
- func (task *Task) UpdateStatus(status Status)
- func (task *Task) WasRunning() bool
- type TaskDB
- type TaskState
- type URI
- type Volume
Constants ¶
const Masking = "*******"
Masking is the string used for masking environment variables.
Variables ¶
var ErrQueueFull = errors.New("task queue is full")
ErrQueueFull is returned in the event of a full queue. This allows the caller to handle this as they see fit.
Functions ¶
func ApplyMask ¶
func ApplyMask(task *Task)
ApplyMask replaces masked environment variables with a masking string.
func IsTerminal ¶
IsTerminal takes a string representation of a state and returns whether it is terminal or not.
func NotifyCallback ¶
func NotifyCallback(task *Task)
NotifyCallback handles posting a JSON back to the URI given with the task.
Types ¶
type CallbackData ¶
type CallbackData struct { Time int64 `json:"time"` Status string `json:"status"` TaskID string `json:"task_id"` }
CallbackData holds information about the status update.
type DefaultTaskDB ¶
type DefaultTaskDB struct {
// contains filtered or unexported fields
}
DefaultTaskDB is a in-memory implementation of TaskDB.
func NewDefaultTaskDB ¶
func NewDefaultTaskDB() *DefaultTaskDB
NewDefaultTaskDB returns a new instance of TaskDB.
func (*DefaultTaskDB) Clean ¶
func (db *DefaultTaskDB) Clean() error
Clean removes all tasks from the database.
func (*DefaultTaskDB) Close ¶
func (db *DefaultTaskDB) Close()
Close closes the connection to the database.
func (*DefaultTaskDB) DeleteTask ¶ added in v0.27.0
func (db *DefaultTaskDB) DeleteTask(id string) error
Deletes the task with a given id, or an error if not found.
func (*DefaultTaskDB) ListNonTerminalTasks ¶
func (db *DefaultTaskDB) ListNonTerminalTasks() ([]*Task, error)
ListNonTerminalTasks returns all non-terminal tasks.
func (*DefaultTaskDB) PutTask ¶
func (db *DefaultTaskDB) PutTask(task *Task) error
PutTask adds a new task to the database.
func (*DefaultTaskDB) ReadTask ¶
func (db *DefaultTaskDB) ReadTask(id string) (Task, error)
ReadTask returns a task with a given id, or an error if not found.
func (*DefaultTaskDB) ReadUnmaskedTask ¶
func (db *DefaultTaskDB) ReadUnmaskedTask(id string) (Task, error)
ReadUnmaskedTask returns a task with all its environment variables unmasked.
type Port ¶
type Port struct { ContainerPort uint32 `json:"container_port"` HostPort uint32 `json:"host_port"` Protocol string `json:"protocol"` }
Port defines a port mapping.
type Request ¶
type Request struct { TaskCPUs float64 `json:"task_cpus"` TaskMem float64 `json:"task_mem"` DockerImage string `json:"docker_image"` Command string `json:"command"` Args []string `json:"args"` Volumes []Volume `json:"volumes"` Ports []Port `json:"ports"` Network string `json:"network"` DNS string `json:"dns"` Environment map[string]string `json:"env"` MaskedEnvironment map[string]string `json:"masked_env"` SlaveConstraints []SlaveConstraint `json:"slave_constraints"` CallbackURI string `json:"callback_uri"` URIs []string `json:"uris"` Fetch []URI `json:"fetch"` ForcePullImage bool `json:"force_pull_image"` }
Request represents the structure of a job request
type Scheduler ¶
type Scheduler interface { ScheduleTask(request Request) (string, error) Kill(taskID string) error }
Scheduler defines an interface for scheduling tasks.
type SlaveConstraint ¶
type SlaveConstraint struct { AttributeName string `json:"attribute_name"` AttributeValue string `json:"attribute_value"` }
SlaveConstraint is a constraint that is validated for each slave when determining where to schedule a task.
type Task ¶
type Task struct { TaskCPUs float64 `json:"task_cpus"` TaskMem float64 `json:"task_mem"` Command string `json:"command"` Args []string `json:"args"` User string `json:"user"` Environment map[string]string `json:"env"` MaskedEnvironment map[string]string `json:"masked_env"` Image string `json:"image"` Volumes []Volume `json:"volumes"` Ports []Port `json:"ports"` Status []Status `json:"status"` ID string `json:"id"` Name string `json:"name"` Network string `json:"network"` DNS string `json:"dns"` FrameworkID string `json:"framework_id"` SlaveID string `json:"slave_id"` SlaveConstraints []SlaveConstraint `json:"slave_constraints"` Hostname string `json:"hostname"` Retry int `json:"retry"` CallbackURI string `json:"callback_uri"` SandboxPath string `json:"sandbox_path"` AgentIP string `json:"agent_ip"` AgentPort int32 `json:"agent_port"` ForcePullImage bool `json:"force_pull_image"` FetchURIs []URI `json:"fetch"` }
Task defines the properties of a scheduled task.
func (*Task) CurrentStatus ¶ added in v0.27.0
CurrentStatus returns the current TaskState
func (*Task) IsTerminated ¶
IsTerminated returns whether the task has been terminated.
func (*Task) IsTerminating ¶ added in v0.27.0
func (*Task) LastUpdated ¶
LastUpdated returns the time of the latest status update.
func (*Task) UpdateStatus ¶
UpdateStatus updates the current task status.
func (*Task) WasRunning ¶
WasRunning returns whether the task was running at some point.
type TaskDB ¶
type TaskDB interface { Clean() error Close() PutTask(task *Task) error ReadTask(id string) (Task, error) DeleteTask(id string) error ReadUnmaskedTask(id string) (Task, error) ListNonTerminalTasks() ([]*Task, error) }
TaskDB defines the functions needed by the database abstraction layer
type TaskState ¶
type TaskState string
TaskState defines the valid task states.
const ( // Standard mesos states TaskStaging TaskState = "TASK_STAGING" TaskStarting TaskState = "TASK_STARTING" TaskRunning TaskState = "TASK_RUNNING" TaskFinished TaskState = "TASK_FINISHED" TaskFailed TaskState = "TASK_FAILED" TaskKilled TaskState = "TASK_KILLED" TaskLost TaskState = "TASK_LOST" TaskError TaskState = "TASK_ERROR" // Custom eremetic states TaskQueued TaskState = "TASK_QUEUED" TaskTerminating TaskState = "TASK_TERMINATING" )
Valid task states