worker

package
v2.11.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2026 License: GPL-3.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Poller

type Poller struct {
	// contains filtered or unexported fields
}

Poller handles polling for tasks from the coordinator

func NewPoller

func NewPoller(workerID string, coordinatorCli coordinator.Client, handler TaskHandler, index int, labels map[string]string) *Poller

NewPoller creates a new poller instance

func (*Poller) GetState

func (p *Poller) GetState() (isConnected bool, consecutiveFails int, lastError error)

GetState returns the current connection state (for monitoring/testing)

func (*Poller) Run

func (p *Poller) Run(ctx context.Context)

Run starts the polling loop

type RemoteTaskHandlerConfig

type RemoteTaskHandlerConfig struct {
	// WorkerID is the identifier of this worker
	WorkerID string
	// CoordinatorClient is the coordinator client with load balancing support
	CoordinatorClient coordinator.Client
	// DAGStore is the store for DAG definitions
	DAGStore exec.DAGStore
	// DAGRunMgr is the manager for DAG runs
	DAGRunMgr runtime.Manager
	// StateStore is the persistent state store shared across DAG runs.
	StateStore dagstate.Store
	// ServiceRegistry is the service registry
	ServiceRegistry exec.ServiceRegistry
	// PeerConfig is the peer configuration
	PeerConfig config.Peer
	// Config is the main application configuration
	Config *config.Config
	// SecretStore resolves Dagu-managed secrets during execution.
	SecretStore secret.Store
	// ProfileStore resolves profile values during execution.
	ProfileStore profile.Store
}

RemoteTaskHandlerConfig contains configuration for the remote task handler

type TaskHandler

type TaskHandler interface {
	Handle(ctx context.Context, task *coordinatorv1.Task) error
}

TaskHandler defines the interface for executing tasks.

func NewRemoteTaskHandler

func NewRemoteTaskHandler(cfg RemoteTaskHandlerConfig) TaskHandler

NewRemoteTaskHandler creates a new TaskHandler that runs tasks in-process with status pushing and log streaming to the coordinator.

type Worker

type Worker struct {
	// contains filtered or unexported fields
}

Worker represents a worker instance that polls for tasks from the coordinator.

func NewWorker

func NewWorker(
	workerID string,
	maxActiveRuns int,
	coordinatorClient coordinator.Client,
	labels map[string]string,
	cfg *config.Config,
) *Worker

NewWorker creates a new worker instance.

func (*Worker) SetAfterTaskAckHook

func (w *Worker) SetAfterTaskAckHook(hook func(context.Context, *coordinatorv1.Task) bool)

SetAfterTaskAckHook installs a hook that runs after a task claim has been acknowledged but before the worker registers or executes the task. Returning true abandons execution for that claimed task. This is intended for tests.

func (*Worker) SetHandler

func (w *Worker) SetHandler(executor TaskHandler)

SetHandler sets a custom task executor for testing or custom execution logic

func (*Worker) Start

func (w *Worker) Start(ctx context.Context) (err error)

Start begins the worker's operation, launching multiple polling goroutines.

func (*Worker) Stop

func (w *Worker) Stop(ctx context.Context) error

Stop gracefully shuts down the worker.

func (*Worker) WaitReady

func (w *Worker) WaitReady(ctx context.Context) error

WaitReady blocks until the worker appears in coordinator registration.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL