bus

package
v0.4.9 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Kind      EventKind
	Time      time.Time
	Turn      int
	SessionID string
	Data      interface{}
}

Event represents an agent loop event

type EventBus

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

EventBus is a lightweight multi-subscriber broadcaster for agent-loop events

func NewEventBus

func NewEventBus() *EventBus

NewEventBus creates a new in-process event broadcaster

func (*EventBus) Close

func (b *EventBus) Close()

Close closes all subscriber channels and stops future broadcasts

func (*EventBus) Dropped

func (b *EventBus) Dropped(kind EventKind) int64

Dropped returns the number of dropped events for a given kind

func (*EventBus) Emit

func (b *EventBus) Emit(evt Event)

Emit broadcasts an event to all current subscribers without blocking When a subscriber channel is full, the event is dropped for that subscriber

func (*EventBus) Subscribe

func (b *EventBus) Subscribe(buffer int) EventSubscription

Subscribe registers a new subscriber with the requested channel buffer size A non-positive buffer uses the default size

func (*EventBus) Unsubscribe

func (b *EventBus) Unsubscribe(id uint64)

Unsubscribe removes a subscriber and closes its channel

type EventKind

type EventKind int

EventKind represents the type of event

const (
	EventKindLLMRequest EventKind = iota
	EventKindLLMResponse
	EventKindToolBefore
	EventKindToolAfter
	EventKindToolError
	EventKindTurnStart
	EventKindTurnEnd
	EventKindAgentStart
	EventKindAgentEnd
	EventKindError
	EventKindWarning
	EventKindSteering
	EventKindCount
)

func (EventKind) String

func (k EventKind) String() string

type EventLogger

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

EventLogger is a simple subscriber that logs events

func NewEventLogger

func NewEventLogger() *EventLogger

NewEventLogger creates a new event logger

func (*EventLogger) Handle

func (l *EventLogger) Handle(evt Event)

Handle processes an event

func (*EventLogger) On

func (l *EventLogger) On(kind EventKind, handler func(Event))

On registers a handler for a specific event kind

type EventSubscription

type EventSubscription struct {
	ID uint64
	C  <-chan Event
}

EventSubscription identifies a subscriber channel returned by EventBus.Subscribe

type Int64

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

Int64 is an atomic int64 wrapper (compatible with Go 1.18)

func (*Int64) Add

func (i *Int64) Add(delta int64)

Add adds delta to the value

func (*Int64) Load

func (i *Int64) Load() int64

Load returns the current value

Jump to

Keyboard shortcuts

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