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 ¶
- Variables
- type Active
- type Registry
- func (r *Registry[K]) Get(key K) (*Active, bool)
- func (r *Registry[K]) Has(key K) bool
- func (r *Registry[K]) Inject(key K, message string) error
- func (r *Registry[K]) Messages(key K) ([]*schema.Message, error)
- func (r *Registry[K]) Register(key K, loop *loop.Loop, cancel context.CancelFunc)
- func (r *Registry[K]) Stop(key K) error
- func (r *Registry[K]) Unregister(key K)
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]) 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]) Unregister ¶
func (r *Registry[K]) Unregister(key K)
Click to show internal directories.
Click to hide internal directories.