pool

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package pool manages agent worker pools for concurrent request handling

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoWorkerAvailable is returned when all workers are busy and queue is full
	ErrNoWorkerAvailable = errors.New("no worker available")
	// ErrAgentNotFound is returned when the requested agent doesn't exist
	ErrAgentNotFound = errors.New("agent not found")
	// ErrPoolClosed is returned when pool is closed
	ErrPoolClosed = errors.New("pool is closed")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	WorkersPerAgent int // Number of workers per agent (default: 1)
	QueueSize       int // Size of task queue per agent (default: 10)
}

Config holds pool configuration

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns default pool configuration

type Pool

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

Pool manages workers for each agent

func New

func New(agents *agent.Agents, cfg Config) *Pool

New creates a new agent pool

func (*Pool) AllStats

func (p *Pool) AllStats() []Stats

AllStats returns statistics for all agents

func (*Pool) Close

func (p *Pool) Close()

Close shuts down all workers

func (*Pool) Dispatch

func (p *Pool) Dispatch(ctx context.Context, agentName, prompt string) (string, error)

Dispatch sends a task to an agent's pool

func (*Pool) GetStats

func (p *Pool) GetStats(agentName string) (Stats, error)

GetStats returns statistics for an agent

func (*Pool) Initialize

func (p *Pool) Initialize(agentName string) error

Initialize sets up workers for an agent

type Result

type Result struct {
	Output string
	Err    error
}

Result represents the result of a task execution

type Stats

type Stats struct {
	AgentName    string
	TotalWorkers int
	BusyWorkers  int
	QueueLength  int
}

Stats returns pool statistics

type Task

type Task struct {
	AgentName string
	Prompt    string
	Result    chan Result
}

Task represents a queued task

type Worker

type Worker struct {
	ID        int
	AgentName string
	Runner    *agent.Runner
	// contains filtered or unexported fields
}

Worker represents a single worker for an agent

func (*Worker) IsBusy

func (w *Worker) IsBusy() bool

IsBusy returns whether the worker is currently busy

Jump to

Keyboard shortcuts

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