Documentation
¶
Index ¶
- Constants
- Variables
- func New() components.Component
- func WithDispatcherDeliveryTimeout(deliveryTimeout time.Duration) components.Option
- func WithDispatcherEnabled() components.Option
- func WithDispatcherMaxDeliveryRetries(maxDeliveryRetries int) components.Option
- func WithDispatcherMaxWorkers(maxWorkers int) components.Option
- func WithDispatcherPollInterval(pollInterval time.Duration) components.Option
- func WithOutboxIgnoreNoTx(ignoreNoTx bool) components.Option
- func WithOutboxNotifyChannel(notifyChannel string) components.Option
- func WithOutboxSendNotify(sendNotify bool) components.Option
- func WithOutboxTable(tableName string) components.Option
- type Component
Constants ¶
const (
ComponentName = "messaging"
)
Variables ¶
var (
ErrUnknownComponent = fmt.Errorf("component is not the %s component", ComponentName)
)
Functions ¶
func New ¶
func New() components.Component
func WithDispatcherDeliveryTimeout ¶
func WithDispatcherDeliveryTimeout(deliveryTimeout time.Duration) components.Option
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 ¶
func WithDispatcherEnabled() components.Option
WithDispatcherEnabled enables the dispatcher loop. When set, the component will poll the outbox table and listen on the notify channel for new messages. Without this option, the dispatcher will not run.
func WithDispatcherMaxDeliveryRetries ¶
func WithDispatcherMaxDeliveryRetries(maxDeliveryRetries int) components.Option
WithDispatcherMaxDeliveryRetries sets the maximum number of delivery attempts before an event is considered permanently failed and no longer retried.
func WithDispatcherMaxWorkers ¶
func WithDispatcherMaxWorkers(maxWorkers int) components.Option
WithDispatcherMaxWorkers sets the maximum number of concurrent worker goroutines used by the dispatcher to process and deliver events in parallel.
func WithDispatcherPollInterval ¶
func WithDispatcherPollInterval(pollInterval time.Duration) components.Option
WithDispatcherPollInterval sets how often the dispatcher polls the outbox table for new events when no notifications are received on the notify channel.
func WithOutboxIgnoreNoTx ¶
func WithOutboxIgnoreNoTx(ignoreNoTx bool) components.Option
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 ¶
func WithOutboxNotifyChannel(notifyChannel string) components.Option
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 ¶
func WithOutboxSendNotify(sendNotify bool) components.Option
WithOutboxSendNotify configures whether the outbox should send an explicit PostgreSQL NOTIFY after inserting a new event. By default, this is disabled (false).
func WithOutboxTable ¶
func WithOutboxTable(tableName string) components.Option
WithOutboxTable sets the database table name used by the outbox to store and track pending events before they are dispatched.
Types ¶
type Component ¶
type Component struct { components.Base // contains filtered or unexported fields }
func (*Component) Dispatcher ¶
func (c *Component) Dispatcher() *dispatcher.Dispatcher