Documentation
¶
Index ¶
- Constants
- Variables
- func New() modules.Module
- func WithDispatcherDeliveryTimeout(deliveryTimeout time.Duration) modules.Option
- func WithDispatcherEnabled() modules.Option
- func WithDispatcherMaxDeliveryRetries(maxDeliveryRetries int) modules.Option
- func WithDispatcherMaxWorkers(maxWorkers int) modules.Option
- func WithDispatcherPollInterval(pollInterval time.Duration) modules.Option
- func WithOutboxIgnoreNoTx(ignoreNoTx bool) modules.Option
- func WithOutboxNotifyChannel(notifyChannel string) modules.Option
- func WithOutboxSendNotify(sendNotify bool) modules.Option
- func WithOutboxTable(tableName string) modules.Option
- type Module
Constants ¶
const (
ModuleName = "messaging"
)
Variables ¶
var (
ErrUnknownModule = fmt.Errorf("module is not the %s module", ModuleName)
)
Functions ¶
func WithDispatcherDeliveryTimeout ¶
WithDispatcherDeliveryTimeout sets the maximum duration allowed for a batch of events to be delivered before timing out. This acts as a safeguard against workers hanging indefinitely.
func WithDispatcherEnabled ¶
WithDispatcherEnabled enables the dispatcher loop. When set, the module will poll the outbox table and listen on the notify channel for new messages. Without this option, the dispatcher will not run.
func WithDispatcherMaxDeliveryRetries ¶
WithDispatcherMaxDeliveryRetries sets the maximum number of delivery attempts before an event is considered permanently failed and no longer retried.
func WithDispatcherMaxWorkers ¶
WithDispatcherMaxWorkers sets the maximum number of concurrent worker goroutines used by the dispatcher to process and deliver events in parallel.
func WithDispatcherPollInterval ¶
WithDispatcherPollInterval sets how often the dispatcher polls the outbox table for new events when no notifications are received on the notify channel.
func WithOutboxIgnoreNoTx ¶
WithOutboxIgnoreNoTx configures whether inserting outbox events outside of an active transaction should be ignored instead of returning an error. By default, this is disabled (false).
func WithOutboxNotifyChannel ¶
WithOutboxNotifyChannel sets the database NOTIFY channel used to signal listeners when new events are inserted into the outbox table. The same channel is also used by the dispatcher when enabled.
func WithOutboxSendNotify ¶
WithOutboxSendNotify configures whether the outbox should send an explicit PostgreSQL NOTIFY after inserting a new event. By default, this is disabled (false).
func WithOutboxTable ¶
WithOutboxTable sets the database table name used by the outbox to store and track pending events before they are dispatched.
Types ¶
type Module ¶
func (*Module) Dispatcher ¶
func (m *Module) Dispatcher() *dispatcher.Dispatcher