event

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRetryConfig = RetryConfig{
	MaxRetries:  3,
	InitialWait: time.Second,
	MaxWait:     time.Second * 10,
}

DefaultRetryConfig provides sensible default retry settings

Functions

This section is empty.

Types

type Bus

type Bus interface {
	Publisher
	Subscriber
}

type Handler

type Handler func(context.Context, Message) error

func Chain

func Chain(handlers ...Handler) Handler

Chain combines multiple handlers into a single handler

func WithRecovery

func WithRecovery(handler Handler) Handler

WithRecovery wraps a handler with panic recovery

func WithRetry

func WithRetry(handler Handler, config RetryConfig) Handler

WithRetry wraps a handler with retry logic

func WithTimeout

func WithTimeout(handler Handler, timeout time.Duration) Handler

WithTimeout wraps a handler with a timeout

type Message

type Message struct {
	*message.Message

	Source    string
	EventType string
	Timestamp time.Time
}

Message represents a single event in the system

func NewMessage

func NewMessage(eventType, source string, payload any) (Message, error)

type Module

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

Module implements the event system using Watermill

func New

func New() (*Module, error)

New creates a new event module

func (*Module) Configure

func (m *Module) Configure(config config.Config) error

Configure implements module.Module.

func (*Module) Dependencies

func (m *Module) Dependencies() []string

Dependencies implements module.Module.

func (*Module) GetMigrationSources

func (m *Module) GetMigrationSources(projectRoot string) []migration_runner.Source

GetMigrationSources implements module.Module.

func (*Module) Initialize

func (m *Module) Initialize(ctx context.Context, db *gorm.DB, router *gin.Engine) error

Initialize implements core.Module interface

func (*Module) MigrationsDir

func (m *Module) MigrationsDir() string

MigrationsDir implements module.Module.

func (*Module) Name

func (m *Module) Name() string

Name returns the module name

func (*Module) Namespace

func (m *Module) Namespace() module.ModuleNamespace

Namespace implements module.Module.

func (*Module) NewConfig

func (m *Module) NewConfig() config.Config

NewConfig implements module.Module.

func (*Module) ProvidesMigrations

func (m *Module) ProvidesMigrations() bool

ProvidesMigrations implements module.Module.

func (*Module) Publish

func (m *Module) Publish(ctx context.Context, event Message) error

func (*Module) PublishAsync

func (m *Module) PublishAsync(ctx context.Context, event Message) (<-chan error, error)

func (*Module) Run

func (m *Module) Run(ctx context.Context) error

func (*Module) RunHandlers

func (m *Module) RunHandlers(ctx context.Context) error

func (*Module) Shutdown

func (m *Module) Shutdown(ctx context.Context) error

Shutdown implements core.Module interface

func (*Module) Subscribe

func (m *Module) Subscribe(eventType, handlerName string, handler Handler) error

func (*Module) Unsubscribe

func (m *Module) Unsubscribe(eventType string) error

func (*Module) Version

func (m *Module) Version() string

Version implements module.Module.

type Publisher

type Publisher interface {
	Publish(ctx context.Context, event Message) error
	PublishAsync(ctx context.Context, event Message) (<-chan error, error)
}

type RetryConfig

type RetryConfig struct {
	MaxRetries  int
	InitialWait time.Duration
	MaxWait     time.Duration
}

RetryConfig defines retry behavior for event handlers

type Subscriber

type Subscriber interface {
	Subscribe(eventType, handlerName string, handler Handler) error
	Unsubscribe(eventType string) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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