groupcommit

package
v0.14.3 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package groupcommit owns bounded admission and ordered batch lifecycles. Backends own prepared input, transactional execution, and per-request outcomes.

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("group commit coordinator is shut down")

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxBatchRequests int
	MaxBatchEvents   int
	MaxPending       int
	MaxDelay         time.Duration
	FlushTimeout     time.Duration
}

type Coordinator

type Coordinator[P, R any] struct {
	// contains filtered or unexported fields
}

func New

func New[P, R any](cfg Config, execute Executor[P, R]) *Coordinator[P, R]

New requires normalized positive bounds; backend configuration owns defaults.

func (*Coordinator[P, R]) Close

func (s *Coordinator[P, R]) Close()

func (*Coordinator[P, R]) Closed

func (s *Coordinator[P, R]) Closed() bool

func (*Coordinator[P, R]) Config

func (s *Coordinator[P, R]) Config() Config

Config returns a copy of the immutable batching policy.

func (*Coordinator[P, R]) Pending

func (s *Coordinator[P, R]) Pending(boundary string) int

Pending reports queued requests, excluding the batch currently executing.

func (*Coordinator[P, R]) Submit

func (s *Coordinator[P, R]) Submit(ctx context.Context, boundary string, prepared P, events int) (R, error)

type Executor

type Executor[P, R any] func(context.Context, string, []P) ([]R, error)

Executor must return exactly one outcome per input in input order, only after transaction completion. A returned error invalidates the entire outcome set. A caller cancellation never cancels the shared transaction.

Jump to

Keyboard shortcuts

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