event

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2025 License: MIT 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 an event bus that dispatches events to registered handlers

func GetGlobalBus

func GetGlobalBus() *Bus

GetGlobalBus returns the global event bus instance

func NewBus

func NewBus() *Bus

NewBus creates a new event bus

func (*Bus) Publish

func (b *Bus) Publish(ctx context.Context, event Event) []error

Publish publishes an event to all registered handlers

func (*Bus) Subscribe

func (b *Bus) Subscribe(eventType string, handler Handler)

Subscribe registers a handler for a specific event type

func (*Bus) Unsubscribe

func (b *Bus) Unsubscribe(eventType string, handler Handler)

Unsubscribe removes a handler for a specific event type

type Event

type Event struct {
	Type    string         `json:"type"`
	Payload map[string]any `json:"payload"`
}

Event represents a serverless event

type Handler

type Handler func(ctx context.Context, event Event) error

Handler is a function that handles an event

Jump to

Keyboard shortcuts

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