Documentation
¶
Index ¶
- Variables
- type DistributedRuntime
- func (r *DistributedRuntime) Broadcast(msg *agent.Message) error
- func (r *DistributedRuntime) Call(ctx context.Context, target string, input *agent.Message) (*agent.Message, error)
- func (r *DistributedRuntime) CallParallel(ctx context.Context, targets []string, input *agent.Message) (map[string]*agent.Message, map[string]error)
- func (r *DistributedRuntime) Connect(name, addr string) error
- func (r *DistributedRuntime) Get(name string) (agent.Agent, error)
- func (r *DistributedRuntime) List() []string
- func (r *DistributedRuntime) Recv(source string) (<-chan *agent.Message, error)
- func (r *DistributedRuntime) Register(a agent.Agent) error
- func (r *DistributedRuntime) Send(target string, msg *agent.Message) error
- func (r *DistributedRuntime) Start(ctx context.Context) error
- func (r *DistributedRuntime) StartAgentsPhased(ctx context.Context, agentDefs map[string]agent.AgentDef) error
- func (r *DistributedRuntime) Stop(ctx context.Context) error
- func (r *DistributedRuntime) Unregister(name string) error
- type DistributedRuntimeConfig
- type LocalRuntime
- func (r *LocalRuntime) Broadcast(msg *agent.Message) error
- func (r *LocalRuntime) Call(ctx context.Context, target string, input *agent.Message) (*agent.Message, error)
- func (r *LocalRuntime) CallParallel(ctx context.Context, targets []string, input *agent.Message) (map[string]*agent.Message, map[string]error)
- func (r *LocalRuntime) Get(name string) (agent.Agent, error)
- func (r *LocalRuntime) GetChannelStats(name string) (capacity, length int, err error)
- func (r *LocalRuntime) List() []string
- func (r *LocalRuntime) Recv(source string) (<-chan *agent.Message, error)
- func (r *LocalRuntime) Register(a agent.Agent) error
- func (r *LocalRuntime) Send(target string, msg *agent.Message) error
- func (r *LocalRuntime) Start(ctx context.Context) error
- func (r *LocalRuntime) StartAgentsPhased(ctx context.Context, agentDefs map[string]agent.AgentDef) error
- func (r *LocalRuntime) Stop(ctx context.Context) error
- func (r *LocalRuntime) Unregister(name string) error
- type Option
- type RuntimeConfig
Constants ¶
This section is empty.
Variables ¶
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) StartAgentsPhased ¶ added in v0.2.3
func (r *DistributedRuntime) StartAgentsPhased(ctx context.Context, agentDefs map[string]agent.AgentDef) error
StartAgentsPhased starts all registered LOCAL agents in dependency order. Remote agents are assumed to be already running on their respective nodes.
Agents are started in phases based on their dependencies:
- Phase 0: Agents with no dependencies
- Phase N: Agents whose dependencies are all in phases < N
Within each phase, agents are started concurrently and the method waits for all of them to report Ready() before proceeding to the next phase.
This method should be called after all agents are registered and after Start() has been called to initialize the runtime.
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) StartAgentsPhased ¶ added in v0.2.3
func (r *LocalRuntime) StartAgentsPhased(ctx context.Context, agentDefs map[string]agent.AgentDef) error
StartAgentsPhased starts all registered agents in dependency order. Agents are started in phases based on their dependencies:
- Phase 0: Agents with no dependencies
- Phase N: Agents whose dependencies are all in phases < N
Within each phase, agents are started concurrently and the method waits for all of them to report Ready() before proceeding to the next phase.
This method should be called after all agents are registered and after Start() has been called to initialize the runtime.
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 WithAgentStartTimeout ¶ added in v0.2.3
WithAgentStartTimeout sets the timeout for waiting for agents to become ready
func WithChannelBufferSize ¶
WithChannelBufferSize sets the channel buffer size for LocalRuntime
func WithMaxConcurrentCalls ¶
WithMaxConcurrentCalls sets the maximum number of concurrent agent calls
func WithMetrics ¶
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
// AgentStartTimeout is the maximum time to wait for an agent to become ready
// Default: 30 seconds
AgentStartTimeout time.Duration
}
RuntimeConfig contains configuration options for creating a runtime
func DefaultConfig ¶
func DefaultConfig() *RuntimeConfig
DefaultConfig returns a RuntimeConfig with sensible defaults