Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Message ¶
type Message struct {
ID string
Topic string
Key string
Payload []byte
Headers map[string]string
Status MessageStatus
Retries int
LastError string
CreatedAt time.Time
ProcessedAt time.Time
}
Message represents an outbox message.
type MessageStatus ¶
type MessageStatus string
MessageStatus represents the status of an outbox message.
const ( StatusPending MessageStatus = "pending" StatusProcessing MessageStatus = "processing" StatusProcessed MessageStatus = "processed" StatusFailed MessageStatus = "failed" )
type Option ¶
type Option interface {
Apply(*Config)
}
An Option configures a Relay instance.
func WithBatchSize ¶
WithBatchSize sets the maximum number of messages fetched per poll cycle.
func WithPollInterval ¶
WithPollInterval sets how often the relay polls for pending messages.
type OptionFunc ¶
type OptionFunc func(*Config)
OptionFunc is a function that configures a Relay config.
type PubSubAdapter ¶
type PubSubAdapter struct {
// contains filtered or unexported fields
}
PubSubAdapter wraps a pubsub.Publisher to satisfy the outbox.Publisher interface.
func NewPubSubAdapter ¶
func NewPubSubAdapter(p pubsub.Publisher, opts ...pubsub.PublishOption) *PubSubAdapter
NewPubSubAdapter creates a new PubSubAdapter.
type Relay ¶
type Relay struct {
// contains filtered or unexported fields
}
Relay polls the Store for pending messages and forwards them to a Publisher.
type Store ¶
type Store interface {
// Save persists messages within the given transaction.
// tx can be pgx.Tx, *sql.Tx, or nil (Store creates its own transaction).
Save(ctx context.Context, tx any, msgs ...Message) error
// FetchPending atomically claims up to limit pending messages for processing.
FetchPending(ctx context.Context, limit int) ([]Message, error)
// MarkProcessed marks messages as successfully processed.
MarkProcessed(ctx context.Context, ids ...string) error
// MarkFailed increments retries and records the error.
// Sets status to failed when max retries reached, else back to pending.
MarkFailed(ctx context.Context, id string, err error) error
}
Store is the interface for outbox message persistence.
Click to show internal directories.
Click to hide internal directories.