Documentation
¶
Index ¶
Constants ¶
View Source
const ( DispatchTimeout = time.Second * 10 * debug.TimeoutMultiplier MaxTaskAttempts = 3 // Nexus service and operation names for worker commands. // TODO: Replace with workerservicepb.WorkerService.ServiceName and // workerservicepb.WorkerService.ExecuteCommands.Name() once the Nexus service // descriptor is published in go.temporal.io/api. ServiceName = "temporal.api.nexusservices.workerservice.v1.WorkerService" OperationName = "ExecuteCommands" )
Variables ¶
This section is empty.
Functions ¶
func CommandTypeName ¶
func CommandTypeName(cmd *workerpb.WorkerCommand) string
func RecordCommandMetrics ¶
func RecordCommandMetrics(commands []*workerpb.WorkerCommand, metricsHandler metrics.Handler, namespaceName string, outcome string)
RecordCommandMetrics records per-command metrics with the given outcome.
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher dispatches worker commands to workers via Nexus.
Failure scenarios:
- No worker polling: matching returns RequestTimeout -> *nexus.HandlerError{Type: UpstreamTimeout}. Retryable -- worker may come up later.
- Worker crashes after receiving the task: matching blocks waiting for a response until context deadline, then returns RequestTimeout. Indistinguishable from "no worker polling". Safe to retry because commands are idempotent (e.g., cancelling a missing activity is a no-op success per the worker contract).
- Transport/RPC failure: *nexus.HandlerError. Retryable.
- Worker failure (worker explicitly returns error): *temporal.ApplicationError or *temporal.CanceledError. Permanent — the worker contract requires success for all defined commands, so this indicates a bug or version incompatibility.
Callers are responsible for enforcing retry limits (see MaxTaskAttempts). These commands are best-effort — the activity will eventually time out anyway — so excessive retries waste resources.
func NewDispatcher ¶
func NewDispatcher( matchingClient resource.MatchingClient, config *configs.Config, metricsHandler metrics.Handler, logger log.Logger, ) *Dispatcher
func (*Dispatcher) Execute ¶
func (d *Dispatcher) Execute( ctx context.Context, task *tasks.WorkerCommandsTask, namespaceName string, ) error
Click to show internal directories.
Click to hide internal directories.