Documentation
¶
Overview ¶
Package runactor composes long-running components under one signal story: named actors run concurrently, the first exit (or failure) ends the whole group, teardown runs LIFO, and an interrupt actor turns SIGINT/SIGTERM into graceful cancellation — a second signal exits hard.
Stdlib + golang.org/x/sync/errgroup only (ADR-0004's framework-free stance). This is the pattern steal from cordis's run.Group, shaped so the drain invariant stays expressible: an actor's context is its shutdown signal, NEVER its task-execution context (see ExecutionScope).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInterrupted = errors.New("interrupted")
ErrInterrupted is the group's cancellation cause when a signal stopped it. Run reports nil for a plain interrupt (graceful shutdown), so this exists for callers that need to distinguish causes via errors.Is on context.Cause.
Functions ¶
func ExecutionScope ¶
func ExecutionScope(parent context.Context, timeout time.Duration) (context.Context, context.CancelFunc)
ExecutionScope derives a task-execution context that shutdown NEVER cancels — bounded only by the per-task deadline. This makes the drain invariant structural (the stranded-in-running lesson): a Ctrl-C lets in-flight tasks finish and record their outcome; the pool's shutdown context stops the LOOP, not the work.
Types ¶
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group runs named actors until one of them returns, then cancels the rest and tears down in reverse registration order.
func (*Group) Ctx ¶
Ctx is the actors' shutdown context: cancelled when the group ends (signal, actor exit, or parent death).
func (*Group) Go ¶
Go runs fn as a named actor. The FIRST actor to return decides the program: an error is the group's cause (surfaced by Run); a clean return while the group is still healthy is a graceful stop.
func (*Group) InterruptOn ¶
InterruptOn cancels the group on any of the signals; a second signal exits the process hard (exit code 130) — the operator's escape hatch when graceful drain hangs.
func (*Group) OnShutdown ¶
OnShutdown registers a teardown step; steps run LIFO after every actor has stopped. Use for Close-ordered resources (store last to close).