Help us shape the future of Go! Take the 2026 Go Developer Survey

handler

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: BSD-2-Clause Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultReconcileInterval = 60 * time.Second

DefaultReconcileInterval is the default interval between reconcile-loop passes (spec 005), overridable per deployment via RECONCILE_INTERVAL. 60s is a reasonable recovery latency for a task whose deferral was lost across a restart.

View Source
const DefaultReconcilePassTimeout = 45 * time.Second

DefaultReconcilePassTimeout bounds one reconcile pass so a slow or large vault cannot hold a pass open indefinitely (spec 005 Failure Modes: "Pass bounded by a per-pass timeout; logs evaluate count so cost is visible"). Three quarters of the interval: a pass completes within a tick and leaves headroom for the next one. Raised from 30s on 2026-10-19 — a pass over the openclaw vault aborted on `context_cancelled` every minute after evaluating only 8-73 of ~200 non-terminal tasks, so the tasks ordered after the cut were never reached. The per-assignee active-Job cache added in the same change removes most of the cost; this is the headroom that keeps a slow pass from re-opening the same window. Overridable per deployment via RECONCILE_PASS_TIMEOUT: on 2026-10-21 a sun executor reading the 15k-file openclaw vault over the git-rest ingress (~7 ms per GET) aborted every pass at 45s with evaluated=0.

Variables

This section is empty.

Functions

func IsTerminal

func IsTerminal(phase domain.TaskPhase) bool

IsTerminal reports whether the given phase is in the terminal set. Tasks at a terminal phase must not be re-spawned; operator intervention is required.

func NewAgentsHandler

func NewAgentsHandler(provider k8s.Provider[agentv1.Config], authSecret string) http.Handler

NewAgentsHandler returns an http.Handler that lists all known agent configs from the in-memory store as JSON. If authSecret is non-empty, requests must include X-Agent-Auth header with the secret.

func NewHealthcheckTriggerHandler

func NewHealthcheckTriggerHandler(
	runner probe.HealthcheckRunner,
) http.Handler

NewHealthcheckTriggerHandler returns an HTTP handler that fires the healthcheck runner once per invocation with fire-and-forget + single-flight semantics. Concurrent invocations collapse into one in-flight run (second request is silently dropped).

The handler uses context.Background() for its internal operations so it is not affected by the caller's context cancellation. The handler only stops when the HTTP server shuts down.

Types

type TaskEventHandler

type TaskEventHandler interface {
	ConsumeMessage(ctx context.Context, msg *sarama.ConsumerMessage) error
	// EvalDeferredRespawns evaluates all pending deferred-respawn entries immediately.
	// Called by RunDeferredRespawnLoop on each tick; also callable directly in tests.
	EvalDeferredRespawns(ctx context.Context) error
	// RunDeferredRespawnLoop polls evalDeferredRespawns every deferredRespawnInterval
	// until ctx is cancelled. Must be run alongside the Kafka consumer.
	RunDeferredRespawnLoop(ctx context.Context) error
	// ReconcileOnce runs one reconcile pass: lists the task files under the
	// configured task glob via git-rest, parses each file's frontmatter, and
	// re-drives every eligible task through the existing spawn path. Called by
	// RunReconcileLoop on each tick; also callable directly in tests.
	ReconcileOnce(ctx context.Context) error
	// RunReconcileLoop runs one pass immediately at startup, then every
	// reconcile interval until ctx is cancelled. Must be run
	// alongside the Kafka consumer.
	RunReconcileLoop(ctx context.Context) error
}

TaskEventHandler processes task event messages from Kafka and manages deferred respawns.

func NewTaskEventHandler

func NewTaskEventHandler(
	jobSpawner spawner.JobSpawner,
	branch base.Branch,
	cluster string,
	stageFilter bool,
	runUntagged bool,
	resolver pkg.ConfigResolver,
	resultPublisher pkg.ResultPublisher,
	taskStore *pkg.TaskStore,
	currentDateTime libtime.CurrentDateTimeGetter,
	gitRestClient gitrestclient.GitRestClient,
	taskGlob string,
	reconcilePassTimeout time.Duration,
	reconcileInterval time.Duration,
) TaskEventHandler

NewTaskEventHandler creates a new TaskEventHandler.

Jump to

Keyboard shortcuts

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