eventbus

package
v0.59.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Code generated by gobusgen; DO NOT EDIT.

Package eventbus provides a typed publish/subscribe event bus for cross-component communication within hive.

Index

Constants

This section is empty.

Variables

View Source
var ErrFull = errors.New("event bus buffer full")

ErrFull reports that an event could not be queued because the bus buffer is full. Callers that require delivery can return this error and retry.

View Source
var Events = map[string]any{

	"agent.status-changed":   AgentStatusChangedPayload{},
	"config.reloaded":        ConfigReloadedPayload{},
	"message.received":       MessageReceivedPayload{},
	"notification.published": NotificationPublishedPayload{},
	"repo.focused":           RepoFocusedPayload{},
	"session.corrupted":      SessionCorruptedPayload{},
	"session.created":        SessionCreatedPayload{},
	"session.deleted":        SessionDeletedPayload{},
	"session.recycled":       SessionRecycledPayload{},
	"session.renamed":        SessionRenamedPayload{},
	"todo.created":           TodoCreatedPayload{},
	"tui.started":            TUIStartedPayload{},
	"tui.stopped":            TUIStoppedPayload{},
}

Events defines all event types and their payload structs for code generation.

Functions

func RegisterDebugLogger

func RegisterDebugLogger(bus *EventBus, logger zerolog.Logger)

RegisterDebugLogger registers bus hooks that log all event activity at debug level. Uses OnPublish for event firing, OnDrop for buffer-full warnings, and OnPanic for subscriber panic reporting.

Types

type AgentStatusChangedPayload

type AgentStatusChangedPayload struct {
	Session   *session.Session
	OldStatus terminal.Status
	NewStatus terminal.Status
}

AgentStatusChangedPayload is emitted when an agent's terminal status changes.

type ConfigReloadedPayload

type ConfigReloadedPayload struct {
	Config *config.Config
}

ConfigReloadedPayload is emitted when configuration is reloaded.

type Event

type Event string

Event represents a typed event name.

const (
	EventAgentStatusChanged    Event = "agent.status-changed"
	EventConfigReloaded        Event = "config.reloaded"
	EventMessageReceived       Event = "message.received"
	EventNotificationPublished Event = "notification.published"
	EventRepoFocused           Event = "repo.focused"
	EventSessionCorrupted      Event = "session.corrupted"
	EventSessionCreated        Event = "session.created"
	EventSessionDeleted        Event = "session.deleted"
	EventSessionRecycled       Event = "session.recycled"
	EventSessionRenamed        Event = "session.renamed"
	EventTodoCreated           Event = "todo.created"
	EventTuiStarted            Event = "tui.started"
	EventTuiStopped            Event = "tui.stopped"
)

type EventBus

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

EventBus provides type-safe publish/subscribe for in-process events.

func New

func New(size int) *EventBus

New creates an EventBus with the given channel buffer size.

func (*EventBus) OnDrop

func (bus *EventBus) OnDrop(fn func(Event, any))

OnDrop registers a hook that fires when an event is dropped due to a full buffer.

func (*EventBus) OnPanic

func (bus *EventBus) OnPanic(fn func(Event, any, any))

OnPanic registers a hook that fires when a subscriber panics.

func (*EventBus) OnPublish

func (bus *EventBus) OnPublish(fn func(Event, any))

OnPublish registers a hook that fires after an event is successfully enqueued.

func (*EventBus) OnSubscribe

func (bus *EventBus) OnSubscribe(fn func(Event))

OnSubscribe registers a hook that fires after a subscriber is registered.

func (*EventBus) Publish added in v0.57.0

func (bus *EventBus) Publish(event Event, payload any) error

Publish queues a dynamically named in-process event. Unlike the generated typed publishers, it reports backpressure so callers can preserve durable retry semantics. Dynamic topics are intended for configured integrations; core events should continue to use their generated, typed publishers.

func (*EventBus) PublishAgentStatusChanged

func (bus *EventBus) PublishAgentStatusChanged(payload AgentStatusChangedPayload)

PublishAgentStatusChanged publishes a agent.status-changed event.

func (*EventBus) PublishConfigReloaded

func (bus *EventBus) PublishConfigReloaded(payload ConfigReloadedPayload)

PublishConfigReloaded publishes a config.reloaded event.

func (*EventBus) PublishMessageReceived

func (bus *EventBus) PublishMessageReceived(payload MessageReceivedPayload)

PublishMessageReceived publishes a message.received event.

func (*EventBus) PublishNotificationPublished added in v0.37.1

func (bus *EventBus) PublishNotificationPublished(payload NotificationPublishedPayload)

PublishNotificationPublished publishes a notification.published event.

func (*EventBus) PublishRepoFocused added in v0.38.0

func (bus *EventBus) PublishRepoFocused(payload RepoFocusedPayload)

PublishRepoFocused publishes a repo.focused event.

func (*EventBus) PublishSessionCorrupted

func (bus *EventBus) PublishSessionCorrupted(payload SessionCorruptedPayload)

PublishSessionCorrupted publishes a session.corrupted event.

func (*EventBus) PublishSessionCreated

func (bus *EventBus) PublishSessionCreated(payload SessionCreatedPayload)

PublishSessionCreated publishes a session.created event.

func (*EventBus) PublishSessionDeleted

func (bus *EventBus) PublishSessionDeleted(payload SessionDeletedPayload)

PublishSessionDeleted publishes a session.deleted event.

func (*EventBus) PublishSessionRecycled

func (bus *EventBus) PublishSessionRecycled(payload SessionRecycledPayload)

PublishSessionRecycled publishes a session.recycled event.

func (*EventBus) PublishSessionRenamed

func (bus *EventBus) PublishSessionRenamed(payload SessionRenamedPayload)

PublishSessionRenamed publishes a session.renamed event.

func (*EventBus) PublishTodoCreated added in v0.34.0

func (bus *EventBus) PublishTodoCreated(payload TodoCreatedPayload)

PublishTodoCreated publishes a todo.created event.

func (*EventBus) PublishTuiStarted

func (bus *EventBus) PublishTuiStarted(payload TUIStartedPayload)

PublishTuiStarted publishes a tui.started event.

func (*EventBus) PublishTuiStopped

func (bus *EventBus) PublishTuiStopped(payload TUIStoppedPayload)

PublishTuiStopped publishes a tui.stopped event.

func (*EventBus) Start

func (bus *EventBus) Start(ctx context.Context)

Start begins processing events. It blocks until ctx is cancelled.

func (*EventBus) Subscribe added in v0.57.0

func (bus *EventBus) Subscribe(event Event, fn func(any))

Subscribe registers a handler for a dynamically named in-process event.

func (*EventBus) SubscribeAgentStatusChanged

func (bus *EventBus) SubscribeAgentStatusChanged(fn func(AgentStatusChangedPayload))

SubscribeAgentStatusChanged registers a handler for agent.status-changed events.

func (*EventBus) SubscribeConfigReloaded

func (bus *EventBus) SubscribeConfigReloaded(fn func(ConfigReloadedPayload))

SubscribeConfigReloaded registers a handler for config.reloaded events.

func (*EventBus) SubscribeMessageReceived

func (bus *EventBus) SubscribeMessageReceived(fn func(MessageReceivedPayload))

SubscribeMessageReceived registers a handler for message.received events.

func (*EventBus) SubscribeNotificationPublished added in v0.37.1

func (bus *EventBus) SubscribeNotificationPublished(fn func(NotificationPublishedPayload))

SubscribeNotificationPublished registers a handler for notification.published events.

func (*EventBus) SubscribeRepoFocused added in v0.38.0

func (bus *EventBus) SubscribeRepoFocused(fn func(RepoFocusedPayload))

SubscribeRepoFocused registers a handler for repo.focused events.

func (*EventBus) SubscribeSessionCorrupted

func (bus *EventBus) SubscribeSessionCorrupted(fn func(SessionCorruptedPayload))

SubscribeSessionCorrupted registers a handler for session.corrupted events.

func (*EventBus) SubscribeSessionCreated

func (bus *EventBus) SubscribeSessionCreated(fn func(SessionCreatedPayload))

SubscribeSessionCreated registers a handler for session.created events.

func (*EventBus) SubscribeSessionDeleted

func (bus *EventBus) SubscribeSessionDeleted(fn func(SessionDeletedPayload))

SubscribeSessionDeleted registers a handler for session.deleted events.

func (*EventBus) SubscribeSessionRecycled

func (bus *EventBus) SubscribeSessionRecycled(fn func(SessionRecycledPayload))

SubscribeSessionRecycled registers a handler for session.recycled events.

func (*EventBus) SubscribeSessionRenamed

func (bus *EventBus) SubscribeSessionRenamed(fn func(SessionRenamedPayload))

SubscribeSessionRenamed registers a handler for session.renamed events.

func (*EventBus) SubscribeTodoCreated added in v0.34.0

func (bus *EventBus) SubscribeTodoCreated(fn func(TodoCreatedPayload))

SubscribeTodoCreated registers a handler for todo.created events.

func (*EventBus) SubscribeTuiStarted

func (bus *EventBus) SubscribeTuiStarted(fn func(TUIStartedPayload))

SubscribeTuiStarted registers a handler for tui.started events.

func (*EventBus) SubscribeTuiStopped

func (bus *EventBus) SubscribeTuiStopped(fn func(TUIStoppedPayload))

SubscribeTuiStopped registers a handler for tui.stopped events.

type MessageReceivedPayload

type MessageReceivedPayload struct {
	Topic   string
	Message *messaging.Message
}

MessageReceivedPayload is emitted when a message is received on a topic.

type NotificationPublishedPayload added in v0.37.1

type NotificationPublishedPayload struct {
	Level   notify.Level
	Message string
}

NotificationPublishedPayload is emitted when a user-facing notification is published.

type NotificationRouter added in v0.37.1

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

NotificationRouter maps domain events to user-facing notifications.

func NewNotificationRouter added in v0.37.1

func NewNotificationRouter(bus *EventBus) *NotificationRouter

NewNotificationRouter constructs a router for event-to-notification mappings.

func (*NotificationRouter) Register added in v0.37.1

func (r *NotificationRouter) Register()

Register subscribes all supported event mappings.

type RepoFocusedPayload added in v0.38.0

type RepoFocusedPayload struct {
	RepoKey string
}

RepoFocusedPayload is emitted when the user focuses a repository in the TUI.

type SessionCorruptedPayload

type SessionCorruptedPayload struct {
	Session *session.Session
}

SessionCorruptedPayload is emitted when a session is marked corrupted.

type SessionCreatedPayload

type SessionCreatedPayload struct {
	Session *session.Session
}

SessionCreatedPayload is emitted when a new session is created.

type SessionDeletedPayload

type SessionDeletedPayload struct {
	SessionID string
}

SessionDeletedPayload is emitted when a session is deleted.

type SessionRecycledPayload

type SessionRecycledPayload struct {
	Session *session.Session
}

SessionRecycledPayload is emitted when a session is recycled.

type SessionRenamedPayload

type SessionRenamedPayload struct {
	Session *session.Session
	OldName string
}

SessionRenamedPayload is emitted when a session is renamed.

type TUIStartedPayload

type TUIStartedPayload struct{}

TUIStartedPayload is emitted when the TUI starts.

type TUIStoppedPayload

type TUIStoppedPayload struct{}

TUIStoppedPayload is emitted when the TUI stops.

type TodoCreatedPayload added in v0.34.0

type TodoCreatedPayload struct {
	Todo todo.Todo
}

TodoCreatedPayload is emitted when a new todo item is created.

Directories

Path Synopsis
Package testbus provides test utilities for the event bus.
Package testbus provides test utilities for the event bus.

Jump to

Keyboard shortcuts

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