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

workerloop

package
v0.1.0-rc.41 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package workerloop schedules bounded background-work iterations. callers own work selection, error reporting, and any durable retry state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LifetimeEnded

func LifetimeEnded(ctx context.Context) bool

LifetimeEnded distinguishes process shutdown from an iteration's own deadline. outside Run, explicit cancellation remains ordinary caller control flow.

func Run

func Run(ctx context.Context, config Config) error

Run starts immediately and repeats without waiting while an iteration finds more work and succeeds. empty or failed iterations wait for IdleInterval. each iteration has its own deadline; OnError decides how to report failures, including those returned during caller cancellation.

Types

type Config

type Config struct {
	OperationTimeout time.Duration
	IdleInterval     time.Duration
	Process          Process
	OnError          func(error)
}

Config describes scheduling and leaves failure reporting with the caller.

type Process

type Process func(context.Context) (more bool, err error)

Process performs one iteration and reports whether more work is immediately available. the caller owns any durable retry state.

Jump to

Keyboard shortcuts

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