events

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package events provides an in-process publish/subscribe event bus for the registry server's internal layers (R2-R7) to communicate without importing each other.

The bus is the structural fix for the R5 sibling rule defined in architecture-notes/07-REGISTRY-LAYERS.md: directory, membership, trust, policy, polo, identity, and routing stores never import each other. Cross-store side effects (e.g. directory cache invalidation when membership changes, key-index updates when identity rotates a key) flow through Bus.Publish / Bus.Subscribe instead.

Same shape as pkg/coreapi.EventBus on the daemon side; different package because the registry server's L8 surface is distinct from the daemon's L10 plugin ABI.

This file is Tier R0.2 of the registry-server extraction plan (architecture-notes/08-REGISTRY-EXTRACTION.md). It has zero consumers; subsequent tiers wire it into existing handlers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

type Bus interface {
	Publish(evt Event)
	Subscribe(pattern string) (<-chan Event, func())
}

Bus is the publish/subscribe surface every R-layer codes against.

Publish is non-blocking. If a subscriber's channel is full, the event is dropped for THAT subscriber only; the publisher and other subscribers are unaffected. This keeps mutation-handler latency bounded regardless of subscriber speed.

Subscribe returns a buffered channel and an unsubscribe func. The pattern is matched against Event.Type. Patterns ending in ".*" match any Type beginning with the prefix (e.g. "membership.*" matches "membership.changed" and "membership.created" but not "membership"). A bare "*" matches every Type. Any other pattern matches Type exactly. Source is not part of pattern matching today.

The unsubscribe func removes the subscription and closes the channel. It is safe to call exactly once; further calls are no-ops.

func NewInProcessBus

func NewInProcessBus(bufSize int) Bus

NewInProcessBus returns an in-memory Bus. bufSize is the per-subscriber channel capacity; values <=0 fall back to defaultBufSize. Each subscriber gets its own independent buffer so a slow consumer cannot stall the publisher or peer subscribers.

type Event

type Event struct {
	Source  string
	Type    string
	Payload map[string]any
}

Event is one item published to the Bus. Source is the publishing store ("directory", "membership", "trust", ...). Type is the dot-namespaced event name within that source ("node.deleted", "membership.changed", "key.rotated", ...). Payload keys/values are publisher-defined; subscribers parse them.

Jump to

Keyboard shortcuts

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