history

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

internal/history/events.go

internal/history/history.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Op        OpKind    `json:"op"`
	ID        string    `json:"id"`
	At        time.Time `json:"at,omitempty"`         // revoke/expire
	TokenHash string    `json:"token_hash,omitempty"` // share (hex)
	Src       string    `json:"src,omitempty"`        // share
	Name      string    `json:"name,omitempty"`       // share
	CreatedAt time.Time `json:"created_at,omitempty"` // share
	ExpiresAt time.Time `json:"expires_at,omitempty"` // share
	Reason    string    `json:"reason,omitempty"`     // expire
}

Event is the on-disk representation of a history event. Exactly one of the op-specific fields is populated, determined by Op.

type OpKind

type OpKind string
const (
	OpShare  OpKind = "share"
	OpRevoke OpKind = "revoke"
	OpExpire OpKind = "expire"
)

type Store

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

Store is a single-writer append-only JSONL history store.

func Open

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

Open creates or opens the history file, truncating any trailing partial line that might be left over from a crash.

func (*Store) Append

func (s *Store) Append(ev Event) error

Append serializes ev as JSON, appends a line, and fsyncs.

func (*Store) Close

func (s *Store) Close() error

func (*Store) Replay

func (s *Store) Replay() ([]Event, error)

Replay returns all events in file order. Corrupt interior lines are skipped with a warning; trailing partial lines were already truncated in Open.

Jump to

Keyboard shortcuts

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