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

registry

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package registry tracks running loops by a key of the caller's choice, such as a user or session id, so another goroutine can stop or steer them.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoActiveLoop: the key has no running loop.
	ErrNoActiveLoop = errors.New("loop: no active loop")
	// ErrControlQueueFull: the loop's control queue is full.
	ErrControlQueueFull = errors.New("loop: control queue full")
)

Functions

This section is empty.

Types

type Active

type Active struct {
	Loop   *loop.Loop
	Cancel context.CancelFunc
}

Active is a running Loop with the function that cancels its context.

type Registry

type Registry[K comparable] struct {
	// contains filtered or unexported fields
}

Registry is safe for concurrent use. The zero value is not usable; call New.

func New

func New[K comparable]() *Registry[K]

func (*Registry[K]) Get

func (r *Registry[K]) Get(key K) (*Active, bool)

func (*Registry[K]) Has

func (r *Registry[K]) Has(key K) bool

func (*Registry[K]) Inject

func (r *Registry[K]) Inject(key K, message string) error

func (*Registry[K]) Messages

func (r *Registry[K]) Messages(key K) ([]*schema.Message, error)

func (*Registry[K]) Register

func (r *Registry[K]) Register(key K, loop *loop.Loop, cancel context.CancelFunc)

Register records loop under key, replacing any loop already there.

func (*Registry[K]) Stop

func (r *Registry[K]) Stop(key K) error

func (*Registry[K]) Unregister

func (r *Registry[K]) Unregister(key K)

Jump to

Keyboard shortcuts

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