executor

package
v0.5.2-0...-c11405c Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package executor describes a running engine (an executor): who it is, what it is doing and what it has done. The engine produces these snapshots; reporters (the conductor agent, metrics exporters, your own observers) read them on their own schedules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hostname

func Hostname() string

Hostname is this machine's name, or empty.

func Report

func Report(ctx context.Context, src Source, interval func() time.Duration, minGap time.Duration, send func())

Report calls send now and then every interval() until ctx ends. When src is a Notifier it also sends after each change, but no sooner than minGap after the previous send, so bursts coalesce. interval is re-read each round, so it may change.

Types

type Announcer

type Announcer interface {
	Announce(Change)
}

Announcer hears every Change an engine makes, as it makes it, from the goroutine that made it. Announce must not block.

type Change

type Change struct {
	Kind         ChangeKind
	ActivityID   uuid.UUID
	ActivityType string
	// RootID is the activity's workflow root: its own id for a root.
	RootID uuid.UUID
	// Attempt is set for AttemptStarted and AttemptSucceeded.
	Attempt int
	At      time.Time
}

Change is one lifecycle change this executor made.

type ChangeKind

type ChangeKind int

ChangeKind is a lifecycle change no event is stored for: the activity's own times say it, so it can only be announced as it happens.

const (
	Created          ChangeKind = iota // submitted, runnable now
	Scheduled                          // submitted to run later
	AttemptStarted                     // claimed by this executor
	AttemptSucceeded                   // completed by this executor
)

type Counters

type Counters struct {
	// Claimed counts activities that started executing here.
	Claimed uint64
	// Succeeded completed; Retried asked for another attempt; Failed failed
	// for good; TimedOut ran past their timeout; DeadLettered ran out of
	// attempts.
	Succeeded, Retried, Failed, TimedOut, DeadLettered uint64
	// ClaimsLost counts activities another worker took over from here.
	ClaimsLost uint64
	// HeartbeatFailures counts failed claim renewals.
	HeartbeatFailures uint64
	// LastClaimLag is how long the last claimed activity waited after it
	// was due.
	LastClaimLag time.Duration
}

Counters are what an executor has done since it started.

type Info

type Info struct {
	// ID is unique per run: the engine's InstanceID.
	ID             string
	Queue          string
	ActivityTypes  []string
	MaxConcurrency int
	StartedAt      time.Time
	Hostname       string
	SDK            SDK
	// Labels are tags (region, deploy version) from WorkerConfig.Labels.
	Labels map[string]string
}

Info identifies an executor; it is fixed for the run.

type Notifier

type Notifier interface {
	Changed() <-chan struct{}
}

Notifier is implemented by a Source (such as the engine) that signals state changes: an activity starts or finishes, or a drain begins. Changed returns a channel closed at the next change after the call.

type Observer

type Observer interface {
	ExecutorStarted(src Source)
	ExecutorStopped(id string)
}

Observer hears an executor start and stop and reads the Source on its own schedule. Both calls must return promptly. An engine notifies every Observer registered with WorkerEngine.Observe.

type Running

type Running struct {
	ID        uuid.UUID
	Type      string
	Attempt   int
	StartedAt time.Time
}

Running is an activity an executor is executing.

type SDK

type SDK struct {
	Name, Version, Language string
}

SDK names the RunnerQ SDK the executor runs.

func ThisSDK

func ThisSDK() SDK

ThisSDK names the runnerq-go SDK in this binary; Version is "unknown" without build information.

type Signal

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

Signal implements Notifier for any number of waiters. The zero value is ready to use.

func (*Signal) Changed

func (s *Signal) Changed() <-chan struct{}

Changed returns a channel closed by the next Notify.

func (*Signal) Notify

func (s *Signal) Notify()

Notify wakes everyone waiting on Changed.

type Snapshot

type Snapshot struct {
	Info     Info
	State    State
	Counters Counters
	At       time.Time
}

Snapshot is an executor at a moment.

type Source

type Source interface {
	Snapshot() Snapshot
}

Source provides a running executor's snapshots.

type State

type State struct {
	Running []Running // oldest first
	// Draining means a shutdown has begun: intake has stopped and in-flight
	// activities are finishing.
	Draining bool
}

State is what an executor is doing now.

Jump to

Keyboard shortcuts

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