Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Migrate ¶
Migrate runs the embedded pgoutbox migrations against the given pool. It is the explicit alternative to NewOutbox's auto-migration: callers that want to control when DDL runs (separate startup phase, release pipeline, etc.) should construct the outbox with WithAutoMigrate(false) and invoke Migrate themselves.
Only WithSchema is consulted from opts; other options are accepted for API symmetry but ignored.
Types ¶
type MessageOpts ¶
type MessageOpts struct {
Payload []byte
}
type Outbox ¶
type Outbox interface {
AddFlusher(topic string, flusher Flusher)
AddMessages(ctx context.Context, tx pgx.Tx, topic string, msgs []MessageOpts) error
// ProcessMessages grabs a batch of messages for the given topic, flushes them using the registered Flusher for that
// topic, and deletes them from the outbox if the flush is successful.
ProcessMessages(ctx context.Context, topic string) ([]*sqlc.Message, error)
}
type OutboxOpt ¶
type OutboxOpt func(*outboxImplOpts)
func WithAutoMigrate ¶
WithAutoMigrate controls whether NewOutbox runs the embedded migrations on construction. Defaults to true. Set to false when the caller wants to run migrations explicitly via Migrate (for example, in a separate startup phase or release pipeline).
func WithBatchSize ¶
WithBatchSize sets the maximum number of messages ProcessMessages will acquire and hand to the Flusher per call. Must be > 0. Values are clamped to int32; sizes above math.MaxInt32 fall back to the default.
func WithSchema ¶
type TxFlusher ¶
type TxFlusher interface {
Flusher
FlushWithTx(ctx context.Context, tx pgx.Tx, msgs []*sqlc.Message) error
}
TxFlusher is an optional extension of Flusher. When a registered flusher implements it, ProcessMessages calls FlushWithTx instead of Flush, handing over the same pgx.Tx it used to acquire the messages. This lets the flusher run its own writes in the same transaction that deletes the flushed messages, so the flush and the delete commit (or roll back) atomically.