eventbus

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package eventbus provides the in-process best-effort audit event stream.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Audit model.AuditLog
}

Event is a successfully persisted audit record.

type Hub

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

Hub retains recent events and fans new events out without blocking publishers.

func New

func New(options Options) (*Hub, error)

New creates a Hub. Zero-valued options use the production defaults.

func (*Hub) Close

func (hub *Hub) Close()

Close closes every subscriber and makes future operations inert.

func (*Hub) Publish

func (hub *Hub) Publish(event Event)

Publish retains and broadcasts event without waiting for subscriber reads.

func (*Hub) Subscribe

func (hub *Hub) Subscribe() (<-chan Event, func())

Subscribe returns retained history followed by live events and an idempotent cancel function.

func (*Hub) SubscribeLive

func (hub *Hub) SubscribeLive() (<-chan Event, func())

SubscribeLive returns only events published after the subscription is registered. Like Subscribe, delivery is best effort: a subscriber whose buffer fills is removed without blocking publishers. The returned cancel function is idempotent.

func (*Hub) SubscriberCount

func (hub *Hub) SubscriberCount() int

SubscriberCount returns the number of currently registered subscribers.

type Options

type Options struct {
	HistorySize      int
	SubscriberBuffer int
}

Options controls retained history and each subscriber's live-event backlog.

Jump to

Keyboard shortcuts

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