eventqueue

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: Apache-2.0 Imports: 5 Imported by: 6

Documentation

Overview

Package eventqueue provides implementation for in-memory queue management and event processing.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrQueueClosed indicates that the event queue has been closed.
	ErrQueueClosed = errors.New("queue is closed")
)

Functions

This section is empty.

Types

type Manager

type Manager interface {
	// GetOrCreate returns an existing queue if one exists, or creates a new one.
	GetOrCreate(ctx context.Context, taskID a2a.TaskID) (Queue, error)

	// Get returns an existing queue if one exists.
	Get(ctx context.Context, taskId a2a.TaskID) (Queue, bool)

	// Destroy closes the queue for the specified task and frees all associates resources.
	Destroy(ctx context.Context, taskID a2a.TaskID) error
}

Manager manages event queues on a per-task basis. It provides lifecycle management for task-specific event queues, enabling multiple clients to attach to the same task's event stream.

func NewInMemoryManager

func NewInMemoryManager() Manager

NewInMemoryManager creates a new queue manager

type Queue

type Queue interface {
	Reader
	Writer

	// Close shuts down a connection to the queue.
	Close() error
}

Queue defines the interface for publishing and consuming events generated during agent execution.

func NewInMemoryQueue

func NewInMemoryQueue(size int) Queue

NewInMemoryQueue creates a new queue of desired size

type Reader

type Reader interface {
	// Read dequeues an event or blocks if the queue is empty.
	Read(ctx context.Context) (a2a.Event, error)
}

Reader defines the interface for reading events from a queue. A2A server stack reads events written by [a2asrv.AgentExecutor].

type Writer

type Writer interface {
	// Write enqueues an event or blocks if a bounded queue is full.
	Write(ctx context.Context, event a2a.Event) error
}

Writer defines the interface for writing events to a queue. [a2asrv.AgentExecutor] translates agent responses to Messages, Tasks or Task update events.

Jump to

Keyboard shortcuts

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