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

turnqueue

package
v0.65.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package turnqueue serializes synchronous agent-originated turns per Session.

Index

Constants

View Source
const (
	// MaxDepth bounds callers waiting behind a Session turn. Raise it only when
	// production fan-in shows legitimate bursts are being rejected.
	MaxDepth = 32
	// HoldTimeout bounds queue admission, not the admitted turn. Revisit when
	// observed Session turns routinely create legitimate waits beyond this limit.
	HoldTimeout = 30 * time.Second
)

Variables

View Source
var (
	ErrFull    = errors.New("session turn queue is full")
	ErrTimeout = errors.New("timed out waiting for session turn admission")
)

Functions

This section is empty.

Types

type Queue

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

Queue provides process-local FIFO fairness within one replica. Cluster-wide one-active-turn-per-Session belongs to #643, tracked under #637: its shared lease will replace every in-process admission guard for all turn ingress. Queue must remain only a fairness layer in front of that standard admission seam, never a send-specific correctness boundary competing with the lease.

func New

func New() *Queue

func NewWithLimits

func NewWithLimits(depth int, hold, idle time.Duration) *Queue

func (*Queue) Enqueue

func (q *Queue) Enqueue(ctx context.Context, key string, fn func(context.Context, context.Context, func() error) error) error

Enqueue runs fn in per-key FIFO order. beforeStart must be called by fn after acquiring the runtime single-flight guard and before appending input or starting tools. It closes the cancellation race in the same way as the channel queue's EnqueueControl started contract: a timeout/cancellation that returns before admission makes every later beforeStart fail.

Jump to

Keyboard shortcuts

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