eventbus

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

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

Bus is the default in-memory implementation of event.Bus. It is safe for concurrent use.

func New

func New(chCap int) *Bus

New returns a Bus with the default slow-subscriber policy. chCap is the per-subscription channel capacity.

func NewWithPolicy

func NewWithPolicy(chCap int, p SlowPolicy) *Bus

NewWithPolicy returns a Bus with the given policy.

func (*Bus) Close

func (b *Bus) Close()

Close disconnects every subscription. Idempotent.

func (*Bus) Publish

func (b *Bus) Publish(e event.Event)

Publish delivers e to every matching subscription. Non-blocking.

func (*Bus) Subscribe

func (b *Bus) Subscribe(filter event.Filter) event.Subscription

Subscribe creates a new subscription.

type SlowPolicy

type SlowPolicy struct {
	// DropThreshold is the number of consecutive dropped events after
	// which the subscription is forcibly closed. Zero means "never close".
	DropThreshold int
}

SlowPolicy controls how the bus reacts to slow subscribers.

Jump to

Keyboard shortcuts

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