memory

package
v2.10.1 Latest Latest
Warning

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

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

Documentation

Overview

Package memory is the in-memory ManifestStore and OperationalStore adapter used by tests and by the conformance suite. It has no persistence: state lives only as long as the process.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessStore added in v2.2.0

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

AccessStore is the in-memory adapter for store.AccessStore. One lock covers the list, which is all the atomicity the port asks for.

func NewAccessStore added in v2.2.0

func NewAccessStore() *AccessStore

NewAccessStore returns an empty access list.

func (*AccessStore) DeletePerson added in v2.2.0

func (s *AccessStore) DeletePerson(_ context.Context, email string) error

func (*AccessStore) GetAgentGrant added in v2.5.0

func (s *AccessStore) GetAgentGrant(_ context.Context, id string) (store.AgentGrant, error)

func (*AccessStore) GetPerson added in v2.2.0

func (s *AccessStore) GetPerson(_ context.Context, email string) (store.Person, error)

func (*AccessStore) GrantPerson added in v2.2.0

func (s *AccessStore) GrantPerson(_ context.Context, p store.Person) (store.Person, error)

func (*AccessStore) ListAgentGrants added in v2.5.0

func (s *AccessStore) ListAgentGrants(_ context.Context, email string) ([]store.AgentGrant, error)

func (*AccessStore) ListPeople added in v2.2.0

func (s *AccessStore) ListPeople(context.Context) ([]store.Person, error)

func (*AccessStore) PutAgentGrant added in v2.5.0

func (s *AccessStore) PutAgentGrant(_ context.Context, t store.AgentGrant) error

func (*AccessStore) RecordSignIn added in v2.2.0

func (s *AccessStore) RecordSignIn(_ context.Context, in store.SignIn) (store.Person, error)

func (*AccessStore) RevokeAgentGrant added in v2.5.0

func (s *AccessStore) RevokeAgentGrant(_ context.Context, id string, at time.Time) error

func (*AccessStore) RotateAgentGrant added in v2.5.0

func (s *AccessStore) RotateAgentGrant(_ context.Context, id string, from int) (bool, error)

func (*AccessStore) TouchAgentGrant added in v2.5.0

func (s *AccessStore) TouchAgentGrant(_ context.Context, id string, at time.Time) error

type ApplyJournal

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

ApplyJournal is the in-memory adapter for store.ApplyJournal.

func NewApplyJournal

func NewApplyJournal() *ApplyJournal

NewApplyJournal creates a new in-memory ApplyJournal.

func (*ApplyJournal) ListUnapplied

func (j *ApplyJournal) ListUnapplied(_ context.Context) ([]store.ApplyUnit, error)

ListUnapplied returns every unit with applied=false, oldest first.

func (*ApplyJournal) MarkApplied

func (j *ApplyJournal) MarkApplied(_ context.Context, unitID string) error

MarkApplied marks a unit as applied.

func (*ApplyJournal) PruneOld

func (j *ApplyJournal) PruneOld(_ context.Context, keepCount int) error

PruneOld removes applied units older than keepCount (keeps the most recent). A keepCount of 0 or less means unlimited (no pruning).

func (*ApplyJournal) PutUnit

func (j *ApplyJournal) PutUnit(_ context.Context, unit store.ApplyUnit) error

PutUnit writes a new unit with applied=false.

func (*ApplyJournal) WithinTransaction

func (j *ApplyJournal) WithinTransaction(ctx context.Context, fn func(ctx context.Context, tx store.ApplyJournal) error) error

WithinTransaction runs fn. Memory adapter doesn't need true transactions.

type BundleStore

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

BundleStore keeps handoff bundles in memory: what a test needs to prove a handoff recorded what it rendered, without a directory.

func NewBundleStore

func NewBundleStore() *BundleStore

NewBundleStore returns an empty BundleStore.

func (*BundleStore) Get

func (b *BundleStore) Get(location, name string) ([]byte, bool)

Get returns one stored file, for tests.

func (*BundleStore) PutBundle

func (b *BundleStore) PutBundle(_ context.Context, projectID string, version int, files map[string][]byte) (store.Bundle, error)

PutBundle stores files under "handoff/<project>/v<n>".

type DocStore

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

DocStore is the in-memory adapter for store.DocStore. One lock covers every document, which is all the atomicity the port asks for.

func NewDocStore

func NewDocStore() *DocStore

NewDocStore returns an empty DocStore.

func (*DocStore) Append

func (s *DocStore) Append(_ context.Context, docID string, data []byte) (int64, error)

func (*DocStore) Compact

func (s *DocStore) Compact(_ context.Context, docID string, snapshot []byte, upTo int64) error

Compact ignores a compaction older than the stored one, whose snapshot lacks chunks that are already gone.

func (*DocStore) Create

func (s *DocStore) Create(_ context.Context, kind, id, docID string, snapshot []byte) (string, bool, error)

func (*DocStore) DocumentFor

func (s *DocStore) DocumentFor(_ context.Context, kind, id string) (string, error)

func (*DocStore) Load

func (s *DocStore) Load(_ context.Context, docID string) ([]byte, []store.Chunk, error)

func (*DocStore) ManifestFor

func (s *DocStore) ManifestFor(_ context.Context, docID string) (string, string, error)

func (*DocStore) Since

func (s *DocStore) Since(_ context.Context, docID string, after int64) ([]store.Chunk, error)

type ManifestStore

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

ManifestStore is the in-memory adapter for store.ManifestStore.

func NewManifestStore

func NewManifestStore() *ManifestStore

func (*ManifestStore) Counts

func (m *ManifestStore) Counts(_ context.Context) (map[string]int, error)

func (*ManifestStore) CurrentMany added in v2.3.0

func (m *ManifestStore) CurrentMany(ctx context.Context, kind string, ids []string) ([]store.Version, error)

CurrentMany returns the current version of each of ids that exists.

func (*ManifestStore) CurrentOfKind added in v2.3.0

func (m *ManifestStore) CurrentOfKind(ctx context.Context, kind string) ([]store.Version, error)

CurrentOfKind returns the current version of every manifest of a kind. Memory has no round trips to save, so it answers from the per-manifest calls; it implements the set so the conformance suite checks the same answers here as in every other adapter.

func (*ManifestStore) DecideProposal added in v2.5.0

func (m *ManifestStore) DecideProposal(_ context.Context, id, status, by, reason string, at time.Time, version int) (store.Proposal, error)

DecideProposal decides an open proposal.

func (*ManifestStore) DecideProposalSet added in v2.6.0

func (m *ManifestStore) DecideProposalSet(_ context.Context, set, status, by, reason string, at time.Time, versions map[string]int) ([]store.Proposal, error)

DecideProposalSet decides every proposal of a set, or none.

func (*ManifestStore) DeleteChangeItem added in v2.7.0

func (m *ManifestStore) DeleteChangeItem(_ context.Context, set, kind, id string) error

DeleteChangeItem drops an item.

func (*ManifestStore) Events added in v2.3.0

func (m *ManifestStore) Events(_ context.Context, after int64, limit int) ([]store.Event, error)

Events returns events after a cursor, oldest first.

func (*ManifestStore) Exclude

func (m *ManifestStore) Exclude(_ context.Context, kind, id, name, reason, operator string) error

Exclude records an exclusion for a manifest.

func (*ManifestStore) GetChangeItem added in v2.7.0

func (m *ManifestStore) GetChangeItem(_ context.Context, set, kind, id string) (store.ChangeItem, bool, error)

GetChangeItem returns one item.

func (*ManifestStore) GetChangeSet added in v2.7.0

func (m *ManifestStore) GetChangeSet(_ context.Context, id string) (store.ChangeSet, error)

GetChangeSet returns one change set.

func (*ManifestStore) GetCurrent

func (m *ManifestStore) GetCurrent(_ context.Context, kind, id string) (store.Version, bool, error)

func (*ManifestStore) GetProposal added in v2.5.0

func (m *ManifestStore) GetProposal(_ context.Context, id string) (store.Proposal, error)

GetProposal returns one proposal.

func (*ManifestStore) GetVersion

func (m *ManifestStore) GetVersion(_ context.Context, kind, id string, number int) (store.Version, bool, error)

func (*ManifestStore) GetWorking

func (m *ManifestStore) GetWorking(_ context.Context, kind, id string) ([]byte, bool, error)

GetWorking returns a manifest's working copy (autosave without versioning). Returns found=false when none exists.

func (*ManifestStore) IndexReferences

func (m *ManifestStore) IndexReferences(_ context.Context, fromKind, fromID string, refs []store.Ref) error

func (*ManifestStore) LatestNumber added in v2.3.0

func (m *ManifestStore) LatestNumber(_ context.Context, kind, id string) (int, error)

LatestNumber returns the highest version number, 0 when there is none.

func (*ManifestStore) ListAllVersions

func (m *ManifestStore) ListAllVersions(_ context.Context, limit int, cursor string) ([]store.Version, string, error)

func (*ManifestStore) ListChangeItems added in v2.7.0

func (m *ManifestStore) ListChangeItems(_ context.Context, set string) ([]store.ChangeItem, error)

ListChangeItems returns a change set's items, oldest first.

func (*ManifestStore) ListChangeSets added in v2.7.0

func (m *ManifestStore) ListChangeSets(_ context.Context, f store.ChangeSetFilter) ([]store.ChangeSet, error)

ListChangeSets returns change sets, newest first.

func (*ManifestStore) ListExcluded

func (m *ManifestStore) ListExcluded(_ context.Context) ([]store.Exclusion, error)

ListExcluded returns every excluded manifest, newest first.

func (*ManifestStore) ListIDs

func (m *ManifestStore) ListIDs(_ context.Context, kind string) ([]string, error)

func (*ManifestStore) ListProposals added in v2.5.0

func (m *ManifestStore) ListProposals(_ context.Context, f store.ProposalFilter) ([]store.Proposal, error)

ListProposals returns proposals, newest first.

func (*ManifestStore) ListReferencedBy

func (m *ManifestStore) ListReferencedBy(_ context.Context, fromKind, fromID string) ([]store.Ref, error)

func (*ManifestStore) ListReferencing

func (m *ManifestStore) ListReferencing(_ context.Context, toKind, toID string) ([]store.Summary, error)

func (*ManifestStore) ListSummaries

func (m *ManifestStore) ListSummaries(_ context.Context, kind, query string, refs []store.RefFilter) ([]store.Summary, error)

func (*ManifestStore) ListVersions

func (m *ManifestStore) ListVersions(_ context.Context, kind, id string) ([]store.Version, error)

func (*ManifestStore) MoveChangeSet added in v2.7.0

func (m *ManifestStore) MoveChangeSet(_ context.Context, id, from, to, by, reason string, at time.Time) (store.ChangeSet, error)

MoveChangeSet moves a change set from one status to another.

func (*ManifestStore) PutChangeItem added in v2.7.0

func (m *ManifestStore) PutChangeItem(_ context.Context, it store.ChangeItem) error

PutChangeItem keeps an item.

func (*ManifestStore) PutChangeSet added in v2.7.0

func (m *ManifestStore) PutChangeSet(_ context.Context, cs store.ChangeSet) error

PutChangeSet keeps a change set.

func (*ManifestStore) PutProposal added in v2.5.0

func (m *ManifestStore) PutProposal(_ context.Context, p store.Proposal) error

PutProposal keeps a proposal.

func (*ManifestStore) PutVersion

func (m *ManifestStore) PutVersion(_ context.Context, v store.Version) error

func (*ManifestStore) PutWorking

func (m *ManifestStore) PutWorking(_ context.Context, kind, id string, yamlBytes []byte) error

PutWorking stores a manifest's working copy (autosave without versioning).

func (*ManifestStore) RecordSeries added in v2.3.0

func (m *ManifestStore) RecordSeries(_ context.Context, items []store.SeriesItem) error

RecordSeries appends series items.

func (*ManifestStore) Recover

func (m *ManifestStore) Recover(_ context.Context, kind, id, reason, operator string) error

Recover deletes an exclusion record.

func (*ManifestStore) ReferencingKind added in v2.3.0

func (m *ManifestStore) ReferencingKind(ctx context.Context, toKind string) (map[string][]store.Summary, error)

ReferencingKind returns who references each manifest of toKind.

func (*ManifestStore) SeriesAsOf added in v2.3.0

func (m *ManifestStore) SeriesAsOf(_ context.Context, kind, series string, ids []string, at time.Time) (map[string][]store.SeriesItem, error)

SeriesAsOf merges each key's items into its value at at.

func (*ManifestStore) WithinTransaction

func (m *ManifestStore) WithinTransaction(ctx context.Context, fn func(ctx context.Context, tx store.ManifestStore) error) error

WithinTransaction is a best-effort transaction: the in-memory store holds one global lock for the duration of fn, and rolls back by snapshotting and restoring state if fn returns an error. This gives the same all-or-nothing guarantee the SQLite adapter gives, without needing a real transaction manager for a map.

type OperationalStore

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

OperationalStore is the in-memory adapter for store.OperationalStore.

func NewOperationalStore

func NewOperationalStore() *OperationalStore

func (*OperationalStore) CurrentStates added in v2.3.0

func (o *OperationalStore) CurrentStates(_ context.Context, projectIDs []string) (map[string]string, error)

CurrentStates returns the latest state of each project with history.

func (*OperationalStore) ListProjectStateHistory

func (o *OperationalStore) ListProjectStateHistory(_ context.Context, projectID string) ([]store.ProjectStateEntry, error)

func (*OperationalStore) LogTo added in v2.3.0

LogTo has the store write its events to m's event log, as a database keeps one log for every table.

func (*OperationalStore) PutProjectStateTransition

func (o *OperationalStore) PutProjectStateTransition(_ context.Context, e store.ProjectStateEntry) error

Jump to

Keyboard shortcuts

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