Package-Level Type Names (total 6, in which 5 are exported)
/* sort exporteds by: | */
Type Parameters:
T: process.Runner Builder is a reusable [process.Runner] implementation that uses [BuilderFunc]
on each [Builder.Run] invocation to create a fresh [process.Runner] instance
for implementations that would otherwise be single-use (do not allow calling
Run more than once per instance).buildBuilderFunc[T]runneroption.Of[T]runnerMusync.RWMutex Run implements the [process.Runner] interface. It uses [BuildFunc] to create
a runner, executes it, and discards the instance when complete.
Use [Builder.Runner] to get the currently executing runner instance. Runner returns the runner currently executing via [Builder.Run] It returns
false when no execution is active. setRunner updates the currently execution runner instance.
*Builder : go.pact.im/x/process.Runner
func NewBuilder[T](f BuilderFunc[T]) *Builder[T]
Type Parameters:
T: process.Runner BuilderFunc is a factory function that constructs [process.Runner] instances. Run implements the [process.Runner] interface. It calls the factory function
to create a runner, then delegates to that runner’s Run method.
BuilderFunc : go.pact.im/x/process.Runner
func Identity[T](runner T) BuilderFunc[T]
func NewBuilder[T](f BuilderFunc[T]) *Builder[T]
Group manages a collection of [process.Runner] instances that run
concurrently in the background and can be stopped together.
Use Go method to add runners, Interrupt to signal them to shutdown gracefully,
and Wait to wait for them to complete.ctxcontext.Contextdonechan struct{}musync.Mutexwgsync.WaitGroup Go starts a runner in the background, calling atExit when it finishes. Interrupt signals all runners started before the next [Group.Wait] call to
stop. Run implements the [process.Runner] interface. It runs the callback, then
interrupts all runners in the group and waits for them to complete. Wait blocks until all currently running processes exit.
*Group : go.pact.im/x/process.Runner
func GroupBuilder(ctx context.Context) (*Group, error)
func NewGroup(ctx context.Context) *Group
Hook is a set of hooks for supervisor’s runner. Post is a function that is called before runner’s callback returns.
The result is returned from the callback.
Defaults to a function that returns nil error. Pre is a function that is called on runner’s callback. A non-nil
error is immediately returned from the callback. In that case, an
error from PostHook is ignored.
Defaults to a function that returns nil error.
func NewSupervisor(runner process.Runner, exec flaky.Executor, hook Hook) *Supervisor
Supervisor runs a [process.Runner] alongside a control callback, managing
their concurrent execution and coordinated shutdown. It wraps the runner
with [flaky.Executor] retry logic and pre/post execution hooks.execflaky.ExecutorhookHookintratomic.Pointer[supervisorInterrupter]runnerprocess.Runner Interrupt signals the supervisor to stop the current execution. This method
is non-blocking and returns immediately; it does not wait for execution to
complete.
If no execution is active ([Supervisor.Run] is not being called), this method
does nothing. Otherwise, it signals the process to stop, but the caller must
separately wait for Run to return if synchronization is needed.
It is safe to call from multiple goroutines concurrently. Run executes the supervisor’s managed process concurrently with the provided
callback function without waiting for the initial process startup.
Use [Hook.Pre] and [Hook.Post] to run code in runner’s callback.
It returns an error combining any errors from the callback and runner execution.
Execution timeline:
- T0: Start runner under executor in background goroutine.
- T0: Start callback in current goroutine.
- T1: Callback returns → interrupt executor.
- T1: Executor returns → cancel callback context.
- T2: Wait for executor to complete cleanup → return combined errors.
Only one active Run invocation is permitted per Supervisor instance.
Concurrent or recursive calls will return an error. execute runs the supervised process under the executor with pre/post Run hooks. pre runs post hook of the supervisor. pre runs pre hook of the supervisor.
*Supervisor : go.pact.im/x/process.Runner
func NewSupervisor(runner process.Runner, exec flaky.Executor, hook Hook) *Supervisor
supervisorInterrupter manages the interruption state between
[flaky.Executor], [process.Runner] and [process.Callback].cancelcontext.CancelFuncdonechan struct{}runningboolstopMusync.Mutexstoppedbool Interrupt signals the supervisor to stop execution. afterRunner handles cleanup after the runner completes execution. It cancels the
callback context if an interrupt was requested during execution. shouldStopBeforeRun checks if an interrupt was requested before runner
execution starts. It sets the running flag to true and returns whether
execution should be stopped. It panics if the executor wasn’t properly
interrupted after a stop was requested.
func (*Supervisor).execute(ctx context.Context, intr *supervisorInterrupter) error
Package-Level Functions (total 5, all are exported)
GroupBuilder is a [BuilderFunc] function for the [Group] type.
Type Parameters:
T: process.Runner Identity returns a [BuilderFunc] that always returns the given runner.
Type Parameters:
T: process.Runner NewBuilder returns a new [Builder] instance for the given factory function.
The function will be called each time [Builder.Run] method is invoked to
create a fresh runner instance.
NewGroup returns a new [Group] instance that runs processes in the background
under the given context.
NewSupervisor returns a new [Supervisor] instance for the given runner.
Package-Level Variables (total 2, neither is exported)
errInterrupt is an internal error used to distinguish between supervisor
interrupts and other errors.
errRecursiveOrConcurrentRun is an error that [Supervisor] returns on
recursive or concurrent Run call.
The pages are generated with Goldsv0.7.6. (GOOS=linux GOARCH=amd64)