Documentation ¶
Overview ¶
Package worker manages the execution and queue of tasks.
Index ¶
- type Connection
- type Worker
- func (w *Worker) Connection() Connection
- func (w *Worker) EnqueueDeferredTasks()
- func (w *Worker) IsActive() bool
- func (w *Worker) SetConnection(conn Connection)
- func (w *Worker) Stop(ctx context.Context)
- func (w *Worker) SubmitDeferredTasks(tasks ...task.Task) (err error)
- func (w *Worker) SubmitTasks(tasks ...task.Task) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection interface { SendProAttachment(proToken string) error SendLandscapeConfig(lpeConfig, hostagentUID string) error Close() }
Connection encapsulates the logic behind sending and receiving messages with the WSL-Pro-Service.
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker contains all the logic around task queueing and execution for one particular distro.
func New ¶
New creates a new worker and starts it. Call Stop when you're done to avoid leaking the task execution goroutine.
func (*Worker) Connection ¶
func (w *Worker) Connection() Connection
Connection returns the client to the WSL task service. Connection returns nil when no connection is set up.
func (*Worker) EnqueueDeferredTasks ¶
func (w *Worker) EnqueueDeferredTasks()
EnqueueDeferredTasks takes all deferred tasks and promotes them to regular tasks.
func (*Worker) IsActive ¶
IsActive returns true when the worker is running, and there exists an active connection to its GRPC service.
func (*Worker) SetConnection ¶
func (w *Worker) SetConnection(conn Connection)
SetConnection removes the connection associated with the distro.
func (*Worker) SubmitDeferredTasks ¶
SubmitDeferredTasks takes one or more tasks into our current worker list.
The task(s) won't wake up the distro, instead wait until it is awake. This does NOT necessarily mean it'll run after non-deferred tasks.
It will return an error if the distro has been cleaned up.
func (*Worker) SubmitTasks ¶
SubmitTasks enqueues one or more task on our current worker list. The task will wake up the distro and be performed as soon as it reaches the beginning of the queue.
It will return an error if the distro has been cleaned up or the task queue is full.