runtime

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAgentNotFound is returned when an agent is not registered
	ErrAgentNotFound = errors.New("agent not found")

	// ErrAgentAlreadyRegistered is returned when trying to register an agent with a duplicate name
	ErrAgentAlreadyRegistered = errors.New("agent already registered")

	// ErrAgentNotReady is returned when trying to execute an agent that is not ready
	ErrAgentNotReady = errors.New("agent not ready")

	// ErrRuntimeNotStarted is returned when trying to use a runtime that hasn't been started
	ErrRuntimeNotStarted = errors.New("runtime not started")

	// ErrRuntimeAlreadyStarted is returned when trying to start an already running runtime
	ErrRuntimeAlreadyStarted = errors.New("runtime already started")
)

Functions

This section is empty.

Types

type DistributedRuntime

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

DistributedRuntime provides distributed agent execution using gRPC. Agents can run in separate processes or on different machines.

func NewDistributedRuntime

func NewDistributedRuntime(listenAddr string, opts ...Option) *DistributedRuntime

NewDistributedRuntime creates a new DistributedRuntime

func (*DistributedRuntime) Broadcast

func (r *DistributedRuntime) Broadcast(msg *agent.Message) error

Broadcast sends a message to all registered agents asynchronously

func (*DistributedRuntime) Call

func (r *DistributedRuntime) Call(ctx context.Context, target string, input *agent.Message) (*agent.Message, error)

Call invokes an agent synchronously and waits for response

func (*DistributedRuntime) CallParallel

func (r *DistributedRuntime) CallParallel(ctx context.Context, targets []string, input *agent.Message) (map[string]*agent.Message, map[string]error)

CallParallel invokes multiple agents concurrently and returns all results

func (*DistributedRuntime) Connect

func (r *DistributedRuntime) Connect(name, addr string) error

Connect establishes a connection to a remote agent

func (*DistributedRuntime) Get

func (r *DistributedRuntime) Get(name string) (agent.Agent, error)

Get retrieves a registered agent by name (local only)

func (*DistributedRuntime) List

func (r *DistributedRuntime) List() []string

List returns all registered agent names (local + remote)

func (*DistributedRuntime) Recv

func (r *DistributedRuntime) Recv(source string) (<-chan *agent.Message, error)

Recv returns a channel to receive messages from a source agent

func (*DistributedRuntime) Register

func (r *DistributedRuntime) Register(a agent.Agent) error

Register registers a local agent with the runtime

func (*DistributedRuntime) Send

func (r *DistributedRuntime) Send(target string, msg *agent.Message) error

Send sends a message to a target agent asynchronously

func (*DistributedRuntime) Start

func (r *DistributedRuntime) Start(ctx context.Context) error

Start starts the runtime and gRPC server

func (*DistributedRuntime) Stop

func (r *DistributedRuntime) Stop(ctx context.Context) error

Stop gracefully shuts down the runtime

func (*DistributedRuntime) Unregister

func (r *DistributedRuntime) Unregister(name string) error

Unregister removes an agent from the runtime

type DistributedRuntimeConfig

type DistributedRuntimeConfig struct {
	*RuntimeConfig
	ListenAddr string // Address to listen for gRPC connections (e.g., ":50051")
}

DistributedRuntimeConfig extends RuntimeConfig with distributed-specific options

type LocalRuntime

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

LocalRuntime provides in-process agent execution using Go channels. All agents run in the same process, ideal for single-binary deployments.

func NewLocalRuntime

func NewLocalRuntime(opts ...Option) *LocalRuntime

NewLocalRuntime creates a new LocalRuntime with the given options

func (*LocalRuntime) Broadcast

func (r *LocalRuntime) Broadcast(msg *agent.Message) error

Broadcast sends a message to all registered agents asynchronously

func (*LocalRuntime) Call

func (r *LocalRuntime) Call(ctx context.Context, target string, input *agent.Message) (*agent.Message, error)

Call invokes an agent synchronously and waits for response

func (*LocalRuntime) CallParallel

func (r *LocalRuntime) CallParallel(ctx context.Context, targets []string, input *agent.Message) (map[string]*agent.Message, map[string]error)

CallParallel invokes multiple agents concurrently and returns all results

func (*LocalRuntime) Get

func (r *LocalRuntime) Get(name string) (agent.Agent, error)

Get retrieves a registered agent by name

func (*LocalRuntime) GetChannelStats

func (r *LocalRuntime) GetChannelStats(name string) (capacity, length int, err error)

GetChannelStats returns statistics for a channel

func (*LocalRuntime) List

func (r *LocalRuntime) List() []string

List returns all registered agent names

func (*LocalRuntime) Recv

func (r *LocalRuntime) Recv(source string) (<-chan *agent.Message, error)

Recv returns a channel to receive messages from a source agent

func (*LocalRuntime) Register

func (r *LocalRuntime) Register(a agent.Agent) error

Register registers an agent with the runtime

func (*LocalRuntime) Send

func (r *LocalRuntime) Send(target string, msg *agent.Message) error

Send sends a message to a target agent asynchronously

func (*LocalRuntime) Start

func (r *LocalRuntime) Start(ctx context.Context) error

Start starts the runtime (no-op for LocalRuntime, agents start individually)

func (*LocalRuntime) Stop

func (r *LocalRuntime) Stop(ctx context.Context) error

Stop gracefully shuts down the runtime

func (*LocalRuntime) Unregister

func (r *LocalRuntime) Unregister(name string) error

Unregister removes an agent from the runtime

type Option

type Option func(*RuntimeConfig)

Option is a functional option for configuring a runtime

func WithChannelBufferSize

func WithChannelBufferSize(size int) Option

WithChannelBufferSize sets the channel buffer size for LocalRuntime

func WithMaxConcurrentCalls

func WithMaxConcurrentCalls(max int) Option

WithMaxConcurrentCalls sets the maximum number of concurrent agent calls

func WithMetrics

func WithMetrics(enabled bool) Option

WithMetrics enables or disables metrics collection

type RuntimeConfig

type RuntimeConfig struct {
	// ChannelBufferSize sets the buffer size for message channels (LocalRuntime only)
	// Default: 100
	ChannelBufferSize int

	// MaxConcurrentCalls limits parallel agent executions (0 = unlimited)
	// Default: 0 (unlimited)
	MaxConcurrentCalls int

	// EnableMetrics enables runtime performance metrics collection
	// Default: true
	EnableMetrics bool
}

RuntimeConfig contains configuration options for creating a runtime

func DefaultConfig

func DefaultConfig() *RuntimeConfig

DefaultConfig returns a RuntimeConfig with sensible defaults

Jump to

Keyboard shortcuts

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