inmem

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package inmem is the in-memory implementation of the artifacts module's stores: repositories, the remote cache, items, the trash can, the package index, builds and their search, Git LFS locks, Bower registrations and archived items, the blob and replica indexes and the cold tier's indexes.

Role

artifacts module, adapter layer (in-memory): the reference implementation of the module's port.Store, over a shared memtx.Store; its remote cache and layout fence are the storekit code it shares with the SQL adapter. The composite in-memory store in app/adapters/inmem builds one Store over its own memtx.Store, delegates every artifacts accessor to it and registers its LayoutWatch with the platform's config store. The package imports the standard library, the kernel, the platform, the module's core and api and storekit only.

Inputs

  • New: the *memtx.Store whose tables hold the rows.
  • The port's calls, with the context of the caller's transaction, if there is one.
  • The watch's Changed: the name of the layout document that the config store's write created, changed or deleted.

Outputs

  • Store, from New, with Repos, RemoteCache, Items, Trash, Packages, Blobs, Replicas, GitLFSLocks, BowerRegistrations, UploadDigests, Builds, ArchivedItems, ColdBlobs and ColdReplicas, LayoutWatch, and memtx's Tx, AfterCommit and Close.

Invariants

  • The rows live in tables of the shared memtx.Store under the SQL tables' names, so every call joins the transaction that the caller's context carries, whichever module's store began it.
  • The repository store writes a remote repository's source record in the transaction that writes its configuration, and Delete removes the repository's cache entries, Git LFS locks and Bower registrations in its transaction too, as the SQL adapter's invalidation and its tables' foreign keys do, so a write that fails leaves none of them changed (decisions 0003 and 0007).
  • Repository passwords and sensitive header values stay in the configurations as given: sealing at rest is the SQL adapter's, under the master key (decision 0017), and nothing here outlives the process.
  • ColdBlobs and ColdReplicas are the hot tier's blob and replica index code over the cold_blobs and cold_blob_replicas tables, so both tiers keep the same rules (decision 0024).
  • The item and build searches match AQL against the stored rows in place and copy only the hits they return.

References

  • Decision 0003: docs/research/decisions/0003-repository-model.md.
  • Decision 0004: docs/research/decisions/0004-storage-sql-metadata-and-blobs.md.
  • Decision 0007: docs/research/decisions/0007-remote-repositories.md (the remote cache and its fences).
  • Decision 0010: docs/research/decisions/0010-retention-trash-and-gc.md (the trash can and blob garbage collection).
  • Decision 0012: docs/research/decisions/0012-search-and-aql.md.
  • Decision 0014: docs/research/decisions/0014-build-info.md.
  • Decision 0015: docs/research/decisions/0015-testing-and-acceptance.md (the in-memory store is the contract's reference backend).
  • Decision 0017: docs/research/decisions/0017-sealed-columns-and-master-key.md.
  • Decision 0018: docs/research/decisions/0018-package-index.md.
  • Decision 0024: docs/research/decisions/0024-cold-storage-tier.md.
  • Decision 0028: docs/research/decisions/0028-blob-mirroring.md.
  • Decision 0044: docs/research/decisions/0044-modular-monolith-migration.md ("Persistence": one in-memory database for every module store, layout fencing as a config watch; "Names the migration introduces", which lists Store, New and LayoutWatch).
  • Target layout: docs/research/architecture-options/5-modular-monolith.md, lines 610 and 611 (the artifacts in-memory adapter) and line 1056 (the metadata store's in-memory store split per owner).
  • Plan: docs/implementation/plan.md#p2-stores, #p5-full-aql-searches-build-info, #p9-remote-repositories and #p9d-modular-monolith-migration, epic STO (https://github.com/weaveplatform/artifactweave/issues/939).
  • https://github.com/weaveplatform/artifactweave/issues/1061
  • https://github.com/weaveplatform/artifactweave/issues/1062

Status

Implemented P2: the repository, item, trash, package and blob stores and the archived items and cold indexes of the archive store, as the metadata store's (pull request 3), and the replica index with the blob mirror (pull request 30). Later phases added the build store (pull request 193), the remote cache (pull request 646), layout fencing (pull request 680), Git LFS locks (pull request 849) and Bower registrations (pull request 912). Moved here in P9d, which added Store, New and LayoutWatch. UploadDigests keeps a Hugging Face LFS upload's SHA-1 and MD5 (#1581).

Testing

inmem_test.go: TestUnitContract runs the artifacts contract (adapters/storetest.Run) on a Store over a fresh memtx.Store. The metadata store's in-memory TestUnitContract runs the same cases through its own store, with RemoteLayoutFences beside them. docker_page_test.go: TestUnitDockerPagesContract runs the Docker page reader's contract (adapters/storetest.RunDockerPages), whose order the in-memory reader gives as the SQL adapter's indexes do. puppet_page_test.go: TestUnitVersionNamesContract runs adapters/storetest.RunVersionNames, the contract of the package store's VersionNames (#1404), and TestUnitPackagePagesContract runs adapters/storetest.RunPackagePages, the contract of its list paging (#1425, #1426), which package_page.go answers by sorting the map's packages and versions in the SQL indexes' orders. repo_page_test.go: TestUnitRepoPagesContract runs adapters/storetest.RunRepoPages, the contract of the repository window Get Repositories reads (#1408).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct{ *memtx.Store }

Store is the in-memory implementation of the artifacts module's port.Store: the repository, remote cache, item, trash, package, Git LFS lock, Bower, build and archived-item stores, the blob and replica indexes and the cold tier's indexes. It keeps its rows in tables of a shared memtx.Store, under the names of the SQL tables, so every call joins the transaction that the caller's context carries, whichever module's store began it.

func New

func New(db *memtx.Store) *Store

New returns the artifacts module's stores over db.

func (*Store) ArchivedItems

func (s *Store) ArchivedItems() port.ArchivedItemStore

ArchivedItems returns the archived item store: the records archived items leave behind (decision 0024).

func (*Store) Blobs

func (s *Store) Blobs() port.BlobIndex

Blobs returns the blob index over the blobs table: content-addressed, reference-counted rows (decisions 0004 and 0010).

func (*Store) BowerRegistrations

func (s *Store) BowerRegistrations() port.BowerRegistrationStore

BowerRegistrations returns the Bower registration store: the immutable name-to-Git-URL registrations of Bower repositories.

func (*Store) Builds

func (s *Store) Builds() port.BuildStore

Builds returns the build store: build-info runs with their modules, properties, artifacts, dependencies and promotions, and the AQL build search (decision 0014).

func (*Store) ColdBlobs

func (s *Store) ColdBlobs() port.BlobIndex

ColdBlobs returns the cold tier's blob index: the blob index code over the cold_blobs table (decision 0024).

func (*Store) ColdReplicas

func (s *Store) ColdReplicas() port.ReplicaIndex

ColdReplicas returns the cold tier's replica index: the replica index code over the cold_blob_replicas table (decision 0024).

func (*Store) GitLFSLocks

func (s *Store) GitLFSLocks() port.GitLFSLockStore

GitLFSLocks returns the Git LFS lock store: the file locks of Git LFS repositories, kept apart from the LFS objects.

func (*Store) Items

func (s *Store) Items() port.ItemStore

Items returns the item store: items in the canonical form of decision 0004, with their properties and download statistics, and the AQL item search (decision 0012).

func (*Store) LayoutWatch

func (s *Store) LayoutWatch() configdoc.Watch

LayoutWatch returns the config watch that fences remote publication when a layout document is created, changed or deleted: every remote repository that uses the layout as its own or its upstream layout gets a new source generation (storekit.FenceLayoutSources). The composition registers it with the platform's config store, which calls it inside the config write's transaction, so the edit and the fence commit or roll back together (decision 0007).

func (*Store) Packages

func (s *Store) Packages() port.PackageStore

Packages returns the package store: the package index of decision 0018.

func (*Store) RemoteCache

func (s *Store) RemoteCache() port.RemoteCacheStore

RemoteCache returns the remote cache store: storekit's compare-and-swap logic over the remote_sources and remote_cache rows (decision 0007).

func (*Store) Replicas

func (s *Store) Replicas() port.ReplicaIndex

Replicas returns the replica index over the blob_replicas table: which mirror members hold which blobs (decision 0028).

func (*Store) Repos

func (s *Store) Repos() port.RepoStore

Repos returns the repository store: repository configurations and each remote repository's source record, which Create, Update and Delete change in the same transaction (decisions 0003 and 0007). Delete also removes the repository's Git LFS locks, Bower registrations and remote cache entries, as the SQL tables' foreign keys do.

func (*Store) Trash

func (s *Store) Trash() port.TrashStore

Trash returns the trash store: the trash can that deletes fill and restores and expiry empty (decision 0010).

func (*Store) UploadDigests

func (s *Store) UploadDigests() port.UploadDigestStore

UploadDigests returns the upload digest store: the SHA-1 and MD5 an upload computed, by the content's SHA-256.

Jump to

Keyboard shortcuts

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