hitlworker

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package hitlworker runs the periodic sweep that finalizes pending_approval messages whose TTL has elapsed. Each row becomes either expired_approved (sent as-is) or expired_rejected based on the owning agent's hitl_expiration_action column. Body columns are scrubbed in both cases.

Index

Constants

View Source
const DefaultBatchSize = 100

DefaultBatchSize caps how many rows one sweep will try to finalize. The partial index on (approval_expires_at) WHERE status='pending_approval' keeps the list query cheap regardless of total table size.

View Source
const DefaultInterval = 60 * time.Second

DefaultInterval is the sweep cadence. One minute matches the design doc target; short enough that TTL boundaries are honored within a minute, long enough to avoid hot-looping the DB when there's nothing to do.

Variables

This section is empty.

Functions

This section is empty.

Types

type Worker

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

Worker runs the TTL sweep. Construct with New, start with Run.

func New

func New(store *identity.Store, sender *outbound.Sender, usage usage.UsageTracker, fromDomain string) *Worker

New constructs a Worker. fromDomain is the deployment's outbound from-domain (cfg.OutboundSMTP.FromDomain) — used by the self-send loopback branch to stamp the synthetic Message-ID / Received headers the same way internal/agent does on the user-driven approve path. Pass "" if the deployment has no outbound relay configured; the loopback path falls back to "e2a.local" for the host portion.

func (*Worker) Run

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

Run drives the periodic sweep until ctx is cancelled. Returns ctx.Err() on shutdown. Safe to run from its own goroutine; multiple instances across processes are fine because the per-row store operations use row-level locking + status guards.

func (*Worker) RunOnce

func (w *Worker) RunOnce(ctx context.Context)

RunOnce performs a single sweep. Exposed for tests that want deterministic behavior without setting up a ticker.

Jump to

Keyboard shortcuts

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