Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyMask(task *Task)
- func Encode(task *Task) ([]byte, error)
- func IsActive(state TaskState) bool
- func IsArchive(url string) bool
- func IsEnqueued(state TaskState) bool
- func IsTerminal(state TaskState) bool
- func NotifyCallback(task *Task)
- type AgentConstraint
- type CallbackData
- type DefaultTaskDB
- func (db *DefaultTaskDB) Clean() error
- func (db *DefaultTaskDB) Close()
- func (db *DefaultTaskDB) DeleteTask(id string) error
- func (db *DefaultTaskDB) ListTasks(filter *TaskFilter) ([]*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 Status
- type Task
- func (task *Task) CurrentStatus() TaskState
- func (task *Task) IsActive() bool
- func (task *Task) IsEnqueued() bool
- func (task *Task) IsRunning() bool
- func (task *Task) IsTerminated() bool
- func (task *Task) IsTerminating() bool
- func (task *Task) LastUpdated() time.Time
- func (task *Task) UpdateStatus(status Status)
- func (task *Task) WasRunning() bool
- type TaskDB
- type TaskFilter
- type TaskState
- type URI
- type Volume
Constants ¶
const ( DefaultTaskFilterState = "active,queued" TerminatedState = "terminated" ActiveState = "active" QueuedState = "queued" )
Possible states for the TaskFilter. And the default state
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 IsActive ¶ added in v0.29.0
IsActive takes a string representation of a state and returns whether it is active or not.
func IsEnqueued ¶ added in v0.29.0
IsEnqueued takes a string representation of a state and returns whether it is enqueued or not.
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 AgentConstraint ¶ added in v0.28.0
type AgentConstraint struct {
AttributeName string `json:"attribute_name"`
AttributeValue string `json:"attribute_value"`
}
AgentConstraint is a constraint that is validated for each agent when determining where to schedule a task.
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
DeleteTask removes the task with a given id, or an error if not found.
func (*DefaultTaskDB) ListTasks ¶ added in v0.29.0
func (db *DefaultTaskDB) ListTasks(filter *TaskFilter) ([]*Task, error)
ListTasks returns all tasks based on the filter.
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
TaskMem float64
DockerImage string
Command string
Args []string
Volumes []Volume
VolumesFrom []string
Ports []Port
Name string
Network string
DNS string
Environment map[string]string
MaskedEnvironment map[string]string
Labels map[string]string
AgentConstraints []AgentConstraint
CallbackURI string
URIs []string
Fetch []URI
ForcePullImage bool
Privileged bool
}
Request is the internal structure of a Request
type Scheduler ¶
type Scheduler interface {
ScheduleTask(request Request) (string, error)
Kill(taskID string) error
}
Scheduler defines an interface for scheduling tasks.
type Task ¶
type Task struct {
TaskCPUs float64
TaskMem float64
Command string
Args []string
User string
Environment map[string]string
MaskedEnvironment map[string]string
Labels map[string]string
Image string
Volumes []Volume
VolumesFrom []string
Ports []Port
Status []Status
ID string
Name string
Network string
DNS string
FrameworkID string
AgentID string
AgentConstraints []AgentConstraint
Hostname string
Retry int
CallbackURI string
SandboxPath string
AgentIP string
AgentPort int32
ForcePullImage bool
Privileged bool
FetchURIs []URI
}
Task represents the internal structure of a Task object
func (*Task) CurrentStatus ¶ added in v0.27.0
CurrentStatus returns the current TaskState
func (*Task) IsEnqueued ¶ added in v0.29.0
IsEnqueued returns whether the task is in queue.
func (*Task) IsTerminated ¶
IsTerminated returns whether the task has been terminated.
func (*Task) IsTerminating ¶ added in v0.27.0
IsTerminating returns whether a task is in the process of terminating
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)
ListTasks(filter *TaskFilter) ([]*Task, error)
}
TaskDB defines the functions needed by the database abstraction layer
type TaskFilter ¶ added in v0.29.0
TaskFilter represents the query param state
func (TaskFilter) Match ¶ added in v0.29.0
func (filter TaskFilter) Match(task *Task) bool
Match the conditions of TaskFilter with the current task
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
