arrivals

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package arrivals records when the relay received events that were already old on arrival, so retention can age them from receipt instead of from their created_at (event_purge.retention_clock: received).

Only late arrivals are recorded. An event received within the late-arrival threshold of its created_at is aged from created_at, which is at most that much early, so the ledger holds the late arrivals of one keep window rather than every event. It persists as an append-only file of "<event id> <unix seconds>" lines: Flush appends what was recorded since the last flush, and Prune rewrites the file without expired entries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ledger

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

Ledger maps event ids to the unix time they arrived. Safe for concurrent use.

func Open

func Open(path string) (*Ledger, error)

Open loads the ledger at path. A missing file is an empty ledger; malformed lines are skipped.

func (*Ledger) ArrivedAt

func (l *Ledger) ArrivedAt(id string) (int64, bool)

ArrivedAt returns when id arrived, if its arrival was recorded.

func (*Ledger) Flush

func (l *Ledger) Flush() error

Flush appends the arrivals recorded since the last write. On failure they stay queued for the next attempt.

func (*Ledger) Len

func (l *Ledger) Len() int

Len returns the number of recorded arrivals.

func (*Ledger) Prune

func (l *Ledger) Prune(cutoff int64) (int, error)

Prune forgets arrivals at or before cutoff, which no longer keep anything from being purged, and rewrites the file with what remains. It returns how many it forgot.

func (*Ledger) Record

func (l *Ledger) Record(id string, t int64)

Record notes that id arrived at t. The first arrival wins.

Jump to

Keyboard shortcuts

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