journal

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrClosed reports submits to a closed journal.
	ErrClosed = errors.New("journal closed")
	// ErrSubmitTimeout reports a dropped submit after the backpressure window expires.
	ErrSubmitTimeout = errors.New("journal submit timeout")
)

Functions

This section is empty.

Types

type HookRunRecord

type HookRunRecord struct {
	ID          string
	HookName    string
	Source      string
	Outcome     string
	Duration    time.Duration
	PayloadJSON string
	RecordedAt  time.Time
}

HookRunRecord carries one hook audit row into the run store.

type Journal

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

Journal persists per-run events before forwarding them to live subscribers.

func Open

func Open(path string, bus *events.Bus[events.Event], bufCap int) (*Journal, error)

Open creates a new journal writer for one run.

func (*Journal) Close

func (j *Journal) Close(ctx context.Context) error

Close drains the queue, performs a final flush+sync, and closes the file.

func (*Journal) CurrentBufferDepth

func (j *Journal) CurrentBufferDepth() int

CurrentBufferDepth reports the current enqueue depth.

func (*Journal) DBPath

func (j *Journal) DBPath() string

DBPath reports the run.db path owned by the journal.

func (*Journal) DroppedEventCounts

func (j *Journal) DroppedEventCounts() (uint64, uint64)

DroppedEventCounts reports dropped event submissions grouped by whether the dropped event was terminal.

func (*Journal) DropsOnSubmit

func (j *Journal) DropsOnSubmit() uint64

DropsOnSubmit reports the number of submits dropped after backpressure timeout.

func (*Journal) EventsWritten

func (j *Journal) EventsWritten() uint64

EventsWritten reports the number of events durably flushed to disk.

func (*Journal) Path

func (j *Journal) Path() string

Path reports the events.jsonl path owned by the journal.

func (*Journal) RecordHookRun

func (j *Journal) RecordHookRun(ctx context.Context, record HookRunRecord) error

RecordHookRun persists one hook audit record through the serialized journal loop.

func (*Journal) SetBus

func (j *Journal) SetBus(bus *events.Bus[events.Event])

SetBus updates the live fan-out bus used for published journal events.

func (*Journal) Submit

func (j *Journal) Submit(ctx context.Context, ev events.Event) error

Submit enqueues one event for durable append, respecting caller cancellation.

func (*Journal) SubmitWithSeq

func (j *Journal) SubmitWithSeq(ctx context.Context, ev events.Event) (uint64, error)

SubmitWithSeq enqueues one event and waits for the assigned journal sequence.

type Owner

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

Owner retains explicit close ownership for a journal that is passed through preparation objects.

func NewOwner

func NewOwner(j *Journal) *Owner

NewOwner wraps a journal with explicit cleanup ownership.

func (*Owner) Close

func (o *Owner) Close(ctx context.Context) error

Close closes the owned journal at most once and releases ownership.

func (*Owner) Journal

func (o *Owner) Journal() *Journal

Journal returns the owned journal instance, if any.

Jump to

Keyboard shortcuts

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