Internal

internal/adapters/jsonstore

Package jsonstore persists session ledgers as atomic JSON files.

import "github.com/nilstate/scafld/v2/internal/adapters/jsonstore"

Package jsonstore persists session ledgers as atomic JSON files.

Variables

ErrSessionNotFound is returned when a task has no session ledger.

Source: internal/adapters/jsonstore/session_store.go:20

var ErrSessionNotFound = errors.New("session not found")

Types

type SessionStore

Source: internal/adapters/jsonstore/session_store.go:23

SessionStore persists session ledgers below .scafld/runs.

type SessionStore struct {
	Root         string
	TrustChecker session.ReceiptTrustChecker
}
Fields
  • Root string
  • TrustChecker session.ReceiptTrustChecker

func Append(ctx context.Context, taskID string, entry session.Entry, now string) (session.Session, error)

Source: internal/adapters/jsonstore/session_store.go:106

Append appends one evidence entry and atomically writes the replayed ledger.

func AppendTransaction(ctx context.Context, taskID string, now string, derive func(session.Session) ([]session.Entry, error)) (session.Session, error)

Source: internal/adapters/jsonstore/session_store.go:115

AppendTransaction derives and appends zero or more entries while holding the session file lock. Use it when the decision to append depends on the current ledger head and must not race another scafld process.

func List(ctx context.Context) ([]session.Session, error)

Source: internal/adapters/jsonstore/session_store.go:51

List reads all session ledgers under .scafld/runs.

func Load(ctx context.Context, taskID string) (session.Session, error)

Source: internal/adapters/jsonstore/session_store.go:31

Load reads and replays the session ledger for taskID.

func Save(ctx context.Context, ledger session.Session) error

Source: internal/adapters/jsonstore/session_store.go:89

Save atomically replaces the session ledger.