inflight

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package inflight tracks a service's background work across Instance Resets. Work started before a Reset must not write into the store the instance resets afterwards. Tracker counts deferred work (#301): Reset starts a new generation, so work that noted the old one knows to drop itself, and waits for work already running. Loops runs background loops that Reset halts, waits for and later resumes (#307).

Index

Constants

This section is empty.

Variables

View Source
var ErrReset = errors.New("inflight: background work halted by an Instance Reset")

ErrReset is the cancel cause of a Loops generation that Reset ended.

Functions

func Halted added in v0.9.0

func Halted(ctx context.Context) bool

Halted reports whether ctx was cancelled by a Loops Reset. Work that finds it so drops the side effects of state it read before the Reset.

Types

type Loops added in v0.9.0

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

Loops runs a service's background loops in generations (#307): Reset cancels the current generation and waits for its loops, so no iteration from before an Instance Reset outlives it, and Resume starts them again once the Store is reset too (emu.ResetFinisher). The zero value is ready to use.

func (*Loops) Reset added in v0.9.0

func (l *Loops) Reset(ctx context.Context) error

Reset cancels the current generation with ErrReset and waits for its loops, or for ctx to end, which it reports. The loops stay stopped until Resume.

func (*Loops) Resume added in v0.9.0

func (l *Loops) Resume()

Resume starts the loops again after Reset, unless Stop ran meanwhile. Loops of a Reset that ended before they returned may still be finishing.

func (*Loops) Start added in v0.9.0

func (l *Loops) Start(fns ...func(ctx context.Context))

Start runs each of fns in a goroutine until Stop, unless the loops are already running.

func (*Loops) Stop added in v0.9.0

func (l *Loops) Stop(ctx context.Context) error

Stop cancels the loops and waits for them, or for ctx to end.

type Tracker

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

Tracker counts running work and the generations Reset starts. The zero value is ready to use.

func (*Tracker) Enter

func (t *Tracker) Enter()

Enter counts work that starts running.

func (*Tracker) Exit

func (t *Tracker) Exit()

Exit uncounts work counted by Enter.

func (*Tracker) Gen

func (t *Tracker) Gen() uint64

Gen returns the current generation.

func (*Tracker) Next

func (t *Tracker) Next()

Next starts a new generation. Callers hold the lock that guards their pending work, so that work either started before Next (and is waited for) or sees the new generation.

func (*Tracker) Wait

func (t *Tracker) Wait(ctx context.Context) error

Wait waits until no work is running, or returns ctx's error when it ends first.

Jump to

Keyboard shortcuts

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