journal

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestDeleteOpenJSONL

func TestDeleteOpenJSONL() error

func TestGetJournalPath

func TestGetJournalPath() (string, error)

TestGetJournalPath returns the auto-determined path for the local journal file.

Types

type Event

type Event struct {
	ID        uuid.UUID       `json:"id"`
	Type      string          `json:"type"`
	NodeID    uuid.UUID       `json:"node_id"`
	Timestamp time.Time       `json:"timestamp"`
	Payload   json.RawMessage `json:"payload"`
}

func NewEvent

func NewEvent(nodeID uuid.UUID, eventType string, payload json.RawMessage) Event

NewEvent creates a new Event with a random ID, the current UTC timestamp, and the given parameters.

type JSONL

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

func OpenJSONL

func OpenJSONL() (*JSONL, error)

OpenJSONL opens a JSONL journal file at the auto-determined path, creating it if it doesn't exist.

func OpenJSONLPath

func OpenJSONLPath(path string) (*JSONL, error)

OpenJSONLPath opens a JSONL journal file at the provided path, creating it if it doesn't exist.

func TestOpenJSONL

func TestOpenJSONL() (*JSONL, error)

TestOpenJSONL opens a JSONL journal file at the auto-determined path, creating it if it doesn't exist.

func (*JSONL) Append

func (j *JSONL) Append(ctx context.Context, event Event) error

Append marshals the event and appends it as a JSON line to the journal file. It checks for context cancellation before acquiring the write lock.

func (*JSONL) Close

func (j *JSONL) Close() error

Close flushes and closes the underlying journal file.

type Journal

type Journal interface {
	// Append marshals and persists an event to the journal.
	Append(ctx context.Context, event Event) error
}

Journal is the interface for appending events to a persistent event log.

Jump to

Keyboard shortcuts

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