eventbus

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event = mdk.Event

Re-export/alias mdk event types

type EventBus

type EventBus interface {
	mdk.EventBus
	Close() error
}

type EventHandler

type EventHandler = mdk.EventHandler

type InMemBus

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

InMemBus is a thread-safe in-memory implementation of EventBus.

func NewInMemBus

func NewInMemBus() *InMemBus

NewInMemBus creates a new InMemBus.

func (*InMemBus) Close

func (b *InMemBus) Close() error

Close closes the event bus.

func (*InMemBus) Publish

func (b *InMemBus) Publish(ctx context.Context, event Event) error

Publish sends an event to all registered handlers for the event type.

func (*InMemBus) SetAsync

func (b *InMemBus) SetAsync(async bool)

SetAsync enables or disables asynchronous handler execution.

func (*InMemBus) Subscribe

func (b *InMemBus) Subscribe(namespace, eventType string, handler EventHandler) (func(), error)

Subscribe registers a handler for a specific event type.

type NATSBus

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

NATSBus is a NATS-based event bus.

func NewNATSBus

func NewNATSBus(url string) (*NATSBus, error)

NewNATSBus creates a new NATSBus.

func (*NATSBus) Close

func (b *NATSBus) Close() error

Close closes the NATS event bus.

func (*NATSBus) Conn

func (b *NATSBus) Conn() *nats.Conn

Conn returns the underlying NATS connection.

func (*NATSBus) Publish

func (b *NATSBus) Publish(ctx context.Context, event Event) error

Publish publishes an event to NATS.

func (*NATSBus) SetContext

func (b *NATSBus) SetContext(ctx context.Context)

SetContext sets the base context for event handlers and ties the bus lifecycle to it.

func (*NATSBus) Subscribe

func (b *NATSBus) Subscribe(namespace, eventType string, handler EventHandler) (func(), error)

Subscribe subscribes to a topic.

Jump to

Keyboard shortcuts

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