Internal

internal/adapters/jsonstore

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:21

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

Types

type SessionStore

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

SessionStore persists session ledgers below .scafld/runs.

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

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

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

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

func (s SessionStore) 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:122

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 (s SessionStore) List(ctx context.Context) ([]session.Session, error)

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

List reads all session ledgers under .scafld/runs.

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

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

Load reads and replays the session ledger for taskID.

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

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

Save atomically replaces the session ledger.