storage

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

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

func GetEventTableName(eventType string) string

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

func NewDLQWriter(connStr string) (*DLQWriter, error)

NewDLQWriter creates a new DLQ writer with connection pooling

func (*DLQWriter) Close

func (d *DLQWriter) Close()

Close closes the DLQ writer connection pool

func (*DLQWriter) Write

func (d *DLQWriter) Write(ctx context.Context, envelope *messaging.EventEnvelope, err error) error

Write writes a single failed event to the DLQ

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL