router

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package router provides the actor-style event router for agent communication.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentActor

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

AgentActor handles events for a single agent. Each actor runs in its own goroutine and processes events sequentially.

func NewAgentActor

func NewAgentActor(id string, adapter bridge.Adapter, client *ent.Client, logger *slog.Logger) *AgentActor

NewAgentActor creates a new agent actor.

func (*AgentActor) ID

func (a *AgentActor) ID() string

ID returns the agent ID.

func (*AgentActor) Send

func (a *AgentActor) Send(evt *ent.Event)

Send sends an event to the actor's inbox.

func (*AgentActor) Start

func (a *AgentActor) Start(ctx context.Context)

Start starts the actor's event processing loop.

func (*AgentActor) Stop

func (a *AgentActor) Stop()

Stop stops the actor.

type Router

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

Router dispatches events to agent actors.

func New

func New(client *ent.Client, logger *slog.Logger) *Router

New creates a new router.

func (*Router) AgentStatuses

func (r *Router) AgentStatuses() map[string]string

AgentStatuses returns the status of all registered agents. Returns a map of agent ID to status ("online" or "offline").

func (*Router) Agents

func (r *Router) Agents() []string

Agents returns a list of registered agent IDs.

func (*Router) Dispatch

func (r *Router) Dispatch(agentID string, evt *ent.Event) error

Dispatch sends an event to the appropriate agent actor.

func (*Router) DispatchByChannel

func (r *Router) DispatchByChannel(channelID string, evt *ent.Event) error

DispatchByChannel finds the agent for a channel and dispatches the event.

func (*Router) HasAgent

func (r *Router) HasAgent(agentID string) bool

HasAgent checks if an agent is registered.

func (*Router) RegisterAgent

func (r *Router) RegisterAgent(ctx context.Context, agentID string, adapter bridge.Adapter) error

RegisterAgent registers an agent with its adapter.

func (*Router) Stop

func (r *Router) Stop(ctx context.Context)

Stop stops all agent actors.

func (*Router) UnregisterAgent

func (r *Router) UnregisterAgent(ctx context.Context, agentID string) error

UnregisterAgent removes an agent from the router.

Jump to

Keyboard shortcuts

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