event

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEmailEventSender

func NewEmailEventSender(bus Bus) email.Sender

NewEmailEventSender creates a new Sender that publishes events

Types

type Bus

type Bus interface {
	// Publish publishes an event to a topic
	Publish(ctx context.Context, topic string, payload map[string]interface{}, metadata map[string]string) error

	// Subscribe subscribes to a topic with a consumer group
	Subscribe(ctx context.Context, topic string, group string, handler Handler) error

	// Close closes the bus connection
	Close() error
}

Bus defines the interface for an event bus

type EmailSenderWrapper

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

EmailSenderWrapper implements email.Sender using Event Bus

func (*EmailSenderWrapper) Close

func (s *EmailSenderWrapper) Close()

func (*EmailSenderWrapper) Send

func (s *EmailSenderWrapper) Send(ctx context.Context, to, subject, body string) error

type Event

type Event struct {
	ID        string                 `json:"id"`
	Topic     string                 `json:"topic"`
	Payload   map[string]interface{} `json:"payload"`
	Metadata  map[string]string      `json:"metadata,omitempty"`
	Timestamp time.Time              `json:"timestamp"`
}

Event represents a system event

type Handler

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

Handler is a function that processes an event

type RedisBus

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

RedisBus implements Bus using Redis Streams

func NewRedisBus

func NewRedisBus(client redis.UniversalClient) *RedisBus

NewRedisBus creates a new RedisBus

func (*RedisBus) Close

func (b *RedisBus) Close() error

Close closes the bus

func (*RedisBus) Publish

func (b *RedisBus) Publish(ctx context.Context, topic string, payload map[string]interface{}, metadata map[string]string) error

Publish publishes an event to a topic (Redis Stream)

func (*RedisBus) Subscribe

func (b *RedisBus) Subscribe(ctx context.Context, topic string, group string, handler Handler) error

Subscribe subscribes to a topic with a consumer group

Jump to

Keyboard shortcuts

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