sql

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: 9 Imported by: 0

Documentation

Overview

Package sql is the SQL implementation of the releases module's stores: release bundles v1 with their artifacts, keeps, retention audits and exports, and the distribution trackers with their per-peer jobs, with the module's registration with the SQL layer.

Role

releases module, adapter layer (SQL). Store implements the module's port.Store (port.BundleStore and port.DistributionStore over the shared unit of work) over a shared dialect.Store, on SQLite and PostgreSQL alike. Module registers the releases stream (adapters/sql/migrations), seventh in the canonical module order, with no sealed column. The composite SQL store in app/adapters/sql builds one Store over its own dialect store, delegates Bundles and Distribution to it and names Module in its module list. The package imports the standard library, the kernel, the platform, the module's core and its stream only.

Inputs

  • New: a *dialect.Store over a database that holds the releases stream's tables.
  • The port's calls, with the context of the caller's transaction, if there is one.

Outputs

  • Store, from New, with Bundles and Distribution, and the dialect store's Tx, AfterCommit and Close.
  • Module: the name releases and the stream migrations.FS.

Invariants

  • Store is built over the shared *dialect.Store, so every call joins the unit of work that the caller's context carries, whichever module's store began it (decision 0044, "Persistence").
  • The store seals no column, so Module registers none: the keys that sign bundles are in the key pair store (decision 0023), which the access module owns.
  • Replacing a bundle's artifacts clears and rewrites them in one transaction: a replace that fails leaves the list as it was.
  • The SQL text, the table names and the error texts are those the metadata store's SQL store used before the module owned them.

References

  • Decision 0023: docs/research/decisions/0023-release-bundles-and-distribution.md.
  • Decision 0044: docs/research/decisions/0044-modular-monolith-migration.md ("Persistence": one dialect.Module per module in the canonical order; "Names the migration introduces", which lists Store, New and Module).
  • Target layout: docs/research/architecture-options/5-modular-monolith.md, line 353 (the releases adapters), line 620 (the releases SQL adapter) and lines 631 to 633 (RunModule).
  • Plan: docs/implementation/plan.md#p2-stores, #p15-release-bundles-v1-and-distribution and #p9d-modular-monolith-migration, epic STO (https://github.com/weaveplatform/artifactweave/issues/939).
  • https://github.com/weaveplatform/artifactweave/issues/1059

Status

Implemented P2: the bundle and distribution stores, as the metadata store's (pull request 3). Moved here in P9d, which added Store, New and Module. The services that call them arrive with P15.

Testing

  • sql_test.go: TestAccContract runs the releases contract (adapters/storetest.Run) on SQLite in memory and in a file through sqltest.RunModule. The metadata store's contract runs the same cases on PostgreSQL.
  • bundles_test.go: TestAccReleasesClosedDatabase (every call fails on a closed pool), TestAccReleasesCorruptRows (a corrupt document, time or size fails to read) and TestAccReleasesFailingStatements (a keep, export, tracker, job or artifact replace fails when its statement does, and the failed replace leaves the artifacts as they were).

Index

Constants

This section is empty.

Variables

View Source
var Module = dialect.Module{Name: "releases", Migrations: migrations.FS}

Module registers the releases module with the SQL layer: its migration stream, under the name that keys the stream's rows in schema_migrations. The module seals no column.

Functions

This section is empty.

Types

type Store

type Store struct{ *dialect.Store }

Store is the SQL implementation of the releases module's stores. It is built over a shared dialect.Store, so every call joins the transaction that the caller's context carries, whichever module's store began it.

func New

func New(db *dialect.Store) *Store

New returns the releases module's stores over db, which must hold the module stream's tables.

func (*Store) Bundles

func (s *Store) Bundles() port.BundleStore

Bundles returns the release bundle store: bundles with their artifacts, keeps, retention audits and exports (decision 0023).

func (*Store) Distribution

func (s *Store) Distribution() port.DistributionStore

Distribution returns the distribution store: trackers and their per-peer jobs (decision 0023).

Directories

Path Synopsis
Package migrations holds the releases module's migration stream: the SQLite and PostgreSQL schema of the tables the module's SQL adapter owns.
Package migrations holds the releases module's migration stream: the SQLite and PostgreSQL schema of the tables the module's SQL adapter owns.

Jump to

Keyboard shortcuts

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