sqlitejournal

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package sqlitejournal keeps the delivery daemon's journal in its own SQLite file: sessions, bindings and every delivery's state, with the sequence numbers of the messages in it. It implements the delivery package's Journal port and never stores tokens or message bodies.

Index

Constants

This section is empty.

Variables

View Source
var ErrNewerSchema = errors.New("written by a newer aboard")

ErrNewerSchema means the data was written by a newer aboard, whose schema this one doesn't know; reading it could misread it, so Open refuses.

View Source
var ErrNoDelivery = errors.New("no such delivery")

ErrNoDelivery means there is no delivery with the given id.

Functions

func ReadModes

func ReadModes(ctx context.Context, path string) (map[delivery.AgentRef]delivery.Mode, error)

ReadModes returns the delivery modes recorded in the journal at path without opening it for writing or changing its schema, so it can be read while a daemon, perhaps an older one, has it open. A journal that doesn't exist, or predates modes, has none.

Types

type Journal

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

Journal is an open delivery journal.

func Open

func Open(ctx context.Context, path string) (*Journal, error)

Open opens (creating if needed) the journal at path, readable only by its owner, and applies migrations.

func (*Journal) AddDelivery

func (j *Journal) AddDelivery(ctx context.Context, d delivery.Delivery) (int64, error)

AddDelivery records a delivery and its messages in one transaction.

func (*Journal) Bind

func (j *Journal) Bind(ctx context.Context, b delivery.Binding) error

Bind records the session an agent's messages go to, replacing the agent's earlier session and the session's earlier agent: a session is bound to at most one agent.

func (*Journal) BindGeneration

func (j *Journal) BindGeneration(ctx context.Context, b delivery.Binding, advance bool) (delivery.Binding, error)

BindGeneration fences a changed credential explicitly; metadata-only refreshes preserve the generation. Retaining other boards requires explicit activation.

func (*Journal) Bindings

func (j *Journal) Bindings(ctx context.Context) ([]delivery.Binding, error)

Bindings returns every agent's binding.

func (*Journal) Close

func (j *Journal) Close() error

Close closes the journal.

func (*Journal) ConfirmHandoff

func (j *Journal) ConfirmHandoff(ctx context.Context, id string, session delivery.SessionKey, boot string, surviving []delivery.AgentKey, at time.Time) ([]delivery.Delivery, error)

ConfirmHandoff persists evidence for the current, nonterminal whitelist only.

func (*Journal) Deliveries

func (j *Journal) Deliveries(ctx context.Context, states ...delivery.State) ([]delivery.Delivery, error)

Deliveries returns the deliveries in the given states, oldest first, with their messages' sequence numbers in order.

func (*Journal) Handoffs

func (j *Journal) Handoffs(ctx context.Context) ([]delivery.HandoffManifest, error)

Handoffs returns frozen manifests in preparation order for recovery.

func (*Journal) Modes

func (j *Journal) Modes(ctx context.Context) (map[delivery.AgentRef]delivery.Mode, error)

Modes returns every agent's recorded delivery mode.

func (*Journal) PrepareHandoff

PrepareHandoff commits the immutable manifest and every handed delivery together.

func (*Journal) ResolveIdentity

func (j *Journal) ResolveIdentity(ctx context.Context, old, resolved delivery.AgentRef) error

ResolveIdentity promotes unverified journal entries only after their own credential identifies the member. Conflicting resolved state is never overwritten.

func (*Journal) SaveSession

func (j *Journal) SaveSession(ctx context.Context, s delivery.SessionRecord) error

SaveSession records a session's boot id, its harness process, whether it is open and the agent another session took from it.

func (*Journal) Sessions

func (j *Journal) Sessions(ctx context.Context) ([]delivery.SessionRecord, error)

Sessions returns every recorded session.

func (*Journal) SetMode

func (j *Journal) SetMode(ctx context.Context, agent delivery.AgentRef, mode delivery.Mode) error

SetMode records an agent's delivery mode, replacing any earlier one.

func (*Journal) UpdateDelivery

func (j *Journal) UpdateDelivery(ctx context.Context, d delivery.Delivery) error

UpdateDelivery saves a delivery's state, session, attempts, reason, retry time and how far it got in its session.

Jump to

Keyboard shortcuts

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