dispatcher

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// NotifyChannel is the PostgreSQL LISTEN/NOTIFY channel used to receive
	// signals when new events are inserted into the outbox table.
	// Default: "outbox_events"
	NotifyChannel string

	// PollInterval defines how often the dispatcher should poll the outbox
	// table when no notifications are received on the notify channel.
	// Default: 1 second
	PollInterval time.Duration

	// DeliveryTimeout is the maximum duration allowed for processing a batch
	// of events. If exceeded, worker goroutines will be canceled.
	// Default: 10 seconds
	DeliveryTimeout time.Duration

	// MaxDeliveryRetries specifies the maximum number of attempts to deliver
	// an event before it is considered permanently failed.
	// Default: 10
	MaxDeliveryRetries int

	// MaxWorkers defines the maximum number of concurrent worker goroutines
	// the dispatcher will use to process events in parallel.
	// Default: 10
	MaxWorkers int
}

func (*Config) ApplyDefaults

func (c *Config) ApplyDefaults()

type Dispatcher

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

func NewDispatcher

func NewDispatcher(
	log *zerolog.Logger,
	dbpool *pgxpool.Pool,
	eventReader *outbox.Reader,
	cfg Config,
) *Dispatcher

func (*Dispatcher) RegisterMessageHandler

func (d *Dispatcher) RegisterMessageHandler(eventName string, handler event.MessageHandler) error

func (*Dispatcher) Start

func (d *Dispatcher) Start(ctx context.Context) error

func (*Dispatcher) Stop

func (d *Dispatcher) Stop()

Jump to

Keyboard shortcuts

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