bridge

package
v0.400.2 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package bridge connects in-process pubsub events to the ZMQ Bus, enabling real-time event broadcasting to all connected Pando instances and observers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterHandlers

func RegisterHandlers(bus BusRegistrar, instanceID string, svc session.Service, msgSvc message.Service, startedAt time.Time)

RegisterHandlers registers all JSON-RPC handlers on the Bus. instanceID is the local instance identifier (bus.instanceID is unexported). svc is the local session service; startedAt is when this instance started. runner and interrupter are optional: pass nil if message.send / session.interrupt should not be handled by this instance.

func RegisterHandlersWithAgent

func RegisterHandlersWithAgent(bus BusRegistrar, instanceID string, svc session.Service, msgSvc message.Service, startedAt time.Time, runner MessageRunner, interrupter SessionInterrupter)

RegisterHandlersWithAgent registers all JSON-RPC handlers including the agent-backed message.send and session.interrupt methods.

Types

type Bridge

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

Bridge connects the in-process pubsub events to the ZMQ Bus. Only the primary instance should create a Bridge.

func New

func New(bus *ipc.Bus, sessions session.Service, agentSvc agent.Service) *Bridge

New creates a Bridge that forwards session and agent events to the ZMQ Bus.

func (*Bridge) Start

func (b *Bridge) Start(ctx context.Context)

Start begins bridging events. It subscribes to session and agent pubsub events and starts the heartbeat goroutine. It runs until ctx is cancelled.

type BusRegistrar

type BusRegistrar interface {
	RegisterMethod(method string, handler ipc.HandlerFunc)
	Publish(topic string, payload any) error
}

BusRegistrar is the minimal interface needed by RegisterHandlers to register RPC methods. *ipc.Bus satisfies this interface; a test double can also implement it.

type MessageRunner

type MessageRunner interface {
	RunMessage(ctx context.Context, sessionID string, content string) error
}

MessageRunner is the minimal interface used by the bridge to send a user message to a session via the local agent. A local interface is used to avoid import cycles between the bridge and the agent packages. RunMessage starts processing the given user message asynchronously and returns after the agent goroutine is launched. Any streaming events are handled internally.

type SessionInterrupter

type SessionInterrupter interface {
	Cancel(sessionID string)
}

SessionInterrupter is the minimal interface used by the bridge to cancel the running LLM call for a session. A local interface is used to avoid import cycles.

Jump to

Keyboard shortcuts

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