Documentation
¶
Index ¶
- func ByState(i, j *Task) int
- func StartEnqueuer(tasks *Service)
- func StartRunner(ctx context.Context, logger logging.Interface, tasks *Service, maxTasks int) func() error
- type CreateOptions
- type Func
- type ListOptions
- type Multi
- type Service
- func (s *Service) Cancel(taskID resource.ID) (*Task, error)
- func (s *Service) Counter() int
- func (s *Service) Create(opts CreateOptions) (*Task, error)
- func (s *Service) Delete(taskID resource.ID) error
- func (s *Service) Enqueue(taskID resource.ID) (*Task, error)
- func (s *Service) Get(taskID resource.ID) (*Task, error)
- func (s *Service) List(opts ListOptions) []*Task
- type ServiceOptions
- type Status
- type Task
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByState ¶
ByState sorts tasks according to the following order:
1. running (ordered by last updated desc) 2. queued (ordered by last updated asc) 3. pending (ordered by last updated asc) 4. finished (ordered by last updated desc)
func StartEnqueuer ¶
func StartEnqueuer(tasks *Service)
Types ¶
type CreateOptions ¶
type CreateOptions struct {
// Resource that the task belongs to.
Parent resource.Resource
// Program command and any sub commands, e.g. plan, state rm, etc.
Command []string
// Args to pass to program.
Args []string
// Path relative to the pug working directory in which to run the command.
Path string
// Environment variables.
Env []string
// A blocking task blocks other tasks from running on the module or
// workspace.
Blocking bool
// Globally exclusive task - at most only one such task can be running
Exclusive bool
// Set to true to indicate that the task produces JSON output
JSON bool
// Skip queue and immediately start task
Immediate bool
// Call this function after the task has successfully finished
AfterExited func(*Task)
// Call this function after the task is enqueued.
AfterQueued func(*Task)
// Call this function after the task starts running.
AfterRunning func(*Task)
// Call this function after the task fails with an error
AfterError func(*Task)
// Call this function after the task is successfully canceled
AfterCanceled func(*Task)
// Call this function after the task is successfully created
AfterCreate func(*Task)
// Call this function after the task terminates for whatever reason.
AfterFinish func(*Task)
}
type ListOptions ¶
type ListOptions struct {
// Filter tasks by those with a matching module path. Optional.
Path *string
// Filter tasks by status: match task if it has one of these statuses.
// Optional.
Status []Status
// Order tasks by oldest first (true), or newest first (false)
Oldest bool
// Filter tasks by only those that are blocking. If false, both blocking and
// non-blocking tasks are returned.
Blocking bool
// Only return those tasks that are exclusive. If false, both exclusive and
// non-exclusive tasks are returned.
Exclusive bool
// Filter tasks by those with one of the following commands
Command [][]string
// Filter tasks by only those that have an ancestor with the given ID.
// Defaults the zero value, which is the ID of the abstract global entity to
// which all resources belong.
Ancestor resource.ID
}
type Multi ¶
type Multi []*Task
Multi is a group of tasks, each one carrying out the same underyling task but carried out on different resources, e.g. terraform init on multiple modules.
func CreateMulti ¶
CreateMulti invokes the task creating func for each resource id. If the task func fails and returns an error, the error is added to errs.
type Service ¶
func NewService ¶
func NewService(opts ServiceOptions) *Service
func (*Service) Create ¶
func (s *Service) Create(opts CreateOptions) (*Task, error)
Create a task. The task is placed into a pending state and requires enqueuing before it'll be processed.
func (*Service) List ¶
func (s *Service) List(opts ListOptions) []*Task
type ServiceOptions ¶
type Task ¶
type Task struct {
resource.Resource
Command []string
Args []string
Path string
Blocking bool
State Status
Env []string
JSON bool
Immediate bool
Created time.Time
Updated time.Time
// Nil until task finishes with an error
Err error
// Call this function after the task has successfully finished
AfterExited func(*Task)
// Call this function after the task is enqueued.
AfterQueued func(*Task)
// Call this function after the task starts running.
AfterRunning func(*Task)
// Call this function after the task fails with an error
AfterError func(*Task)
// Call this function after the task is successfully canceled
AfterCanceled func(*Task)
// Call this function after the task terminates for whatever reason.
AfterFinish func(*Task)
// contains filtered or unexported fields
}
Task is an execution of a CLI program.