queue

package
v0.0.7-beta Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeadLetterQueue

type DeadLetterQueue struct {
	// contains filtered or unexported fields
}

DeadLetterQueue provides disk-based resilience for failed database writes. When a batch insert fails, the data is serialized to JSON and written to disk. A background replay worker periodically attempts to re-insert failed batches.

func NewDLQ

func NewDLQ(dir string, interval time.Duration, replayFn func(data []byte) error) (*DeadLetterQueue, error)

NewDLQ creates a new Dead Letter Queue that stores failed batches in the given directory. replayFn is called with raw JSON bytes during replay — the caller provides the deserialization + insert logic.

func (*DeadLetterQueue) Enqueue

func (d *DeadLetterQueue) Enqueue(batch interface{}) error

Enqueue serializes the given batch to JSON and writes it to disk. This is called when a database batch insert fails.

func (*DeadLetterQueue) Size

func (d *DeadLetterQueue) Size() int

Size returns the number of files currently in the DLQ directory.

func (*DeadLetterQueue) Stop

func (d *DeadLetterQueue) Stop()

Stop gracefully shuts down the replay worker.

Jump to

Keyboard shortcuts

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