eventbus

package
v2.6.4 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close() error

Close closes the eventbus.

func Publish

func Publish(ctx context.Context, topic string, message any) error

Publish publishes an event.

func SetEventbus

func SetEventbus(eb Eventbus)

SetEventbus sets the eventbus.

Types

type Event

type Event = internal.Event

type EventHandler

type EventHandler = internal.EventHandler

type Eventbus

type Eventbus interface {
	// Close closes the eventbus.
	Close() error
	// Publish publishes an event.
	Publish(ctx context.Context, topic string, message any) error
	// Subscribe subscribes to an event.
	Subscribe(ctx context.Context, topic string, handler EventHandler, balance ...bool) (Subscription, error)
}

func GetEventbus

func GetEventbus() Eventbus

GetEventbus returns the eventbus.

type Subscription added in v2.6.0

type Subscription interface {
	// Unsubscribe cancels the subscription.
	Unsubscribe(ctx context.Context) error
}

func Subscribe

func Subscribe(ctx context.Context, topic string, handler EventHandler, balance ...bool) (Subscription, error)

Subscribe subscribes to an event.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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