Documentation
¶
Overview ¶
Package seqtracker tracks NATS JetStream message sequence numbers in SQLite for crash recovery. It records each received message and its processing status, enabling the consumer to replay missed messages on restart.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SeqTracker ¶
type SeqTracker interface {
// TrackReceived records a newly received message as "pending".
// Idempotent: uses INSERT OR IGNORE so re-delivery doesn't overwrite.
TrackReceived(ctx context.Context, topic string, seq uint64, sessionID, messageID, taskID, runID string) error
// MarkProcessing transitions a message to "processing".
MarkProcessing(ctx context.Context, topic string, seq uint64) error
// MarkCompleted transitions a message to "completed".
MarkCompleted(ctx context.Context, topic string, seq uint64) error
// MarkFailed transitions a message to "failed" with an error message.
MarkFailed(ctx context.Context, topic string, seq uint64, errMsg string) error
// GetLastCompletedSeq returns the highest seq with status=completed for the topic.
// Returns 0 if no completed records exist.
GetLastCompletedSeq(ctx context.Context, topic string) (uint64, error)
// GetLastTerminalSeq returns the highest seq with a terminal status for the topic.
// Returns 0 if no terminal records exist.
GetLastTerminalSeq(ctx context.Context, topic string) (uint64, error)
// IsDuplicate returns true if the seq has already been completed for this topic.
IsDuplicate(ctx context.Context, topic string, seq uint64) (bool, error)
// IsTerminal returns true if the seq already has a terminal status for this topic.
IsTerminal(ctx context.Context, topic string, seq uint64) (bool, error)
// Close closes the database.
Close() error
}
SeqTracker tracks NATS JetStream message processing status.
func NewSQLiteTracker ¶
func NewSQLiteTracker(dbPath string) (SeqTracker, error)
NewSQLiteTracker opens or creates a SQLite database at the given path.
Click to show internal directories.
Click to hide internal directories.