ordered

package
v1.229.0-rc.4 Latest Latest
Warning

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

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

Documentation

Overview

Package ordered runs bounded preparation concurrently and commits in input order.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run[T any](ctx context.Context, opts Options[T]) error

Run prepares at most Concurrency jobs at once and retains at most twice that many uncommitted results. A barrier is prepared only after its predecessors commit. Cancellation joins workers and disposes every uncommitted result before returning.

Types

type Options

type Options[T any] struct {
	Count       int
	Concurrency int
	Barrier     func(int) bool
	Prepare     func(context.Context, int) (T, error)
	Commit      func(int, T, error) error
	Dispose     func(T)
}

Options supplies the isolated preparation and ordered commit operations. Commit receives preparation errors, allowing callers to report and continue.

Jump to

Keyboard shortcuts

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