Documentation
¶
Overview ¶
Package storage provides dead letter queue (DLQ) implementation.
The DLQ stores events that failed processing after maximum retry attempts. Failed events are written to a PostgreSQL table with error details for later analysis and manual recovery.
DLQ schema includes:
- Original event envelope (JSON)
- Error message and type
- Timestamp of failure
- Tenant ID for isolation
Package storage provides database storage utilities including automatic partition management.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetEventTableName ¶
GetEventTableName returns the base table name for an event type. Event type "user_signup" -> "events_user_signup"
Types ¶
type DLQWriter ¶
type DLQWriter struct {
// contains filtered or unexported fields
}
DLQWriter handles writing failed events to the dead letter queue
func NewDLQWriter ¶
NewDLQWriter creates a new DLQ writer with connection pooling
func (*DLQWriter) WriteBatch ¶
func (d *DLQWriter) WriteBatch(ctx context.Context, envelopes []*messaging.EventEnvelope, err error) error
WriteBatch writes a batch of failed events to the DLQ
type PartitionManager ¶
type PartitionManager struct {
// contains filtered or unexported fields
}
PartitionManager handles automatic creation of table partitions. Partitions are created on-demand when a new tenant is encountered.
func NewPartitionManager ¶
func NewPartitionManager(pool *pgxpool.Pool) *PartitionManager
NewPartitionManager creates a new partition manager.
func (*PartitionManager) EnsurePartition ¶
func (pm *PartitionManager) EnsurePartition(ctx context.Context, tableName, tenantID string) error
EnsurePartition ensures a partition exists for the given table and tenant. Creates the partition if it doesn't exist. This is idempotent and safe to call multiple times.