composition

package module
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package composition is the ADR-0019 S4 composition root (endgame P4): the ONE place tq's runtime meets go-cqrs-lite's system/ package. It builds system.New over a durable sqlite engine at the projection home (<db>.readmodel.db) with an EMPTY domain BY DESIGN — the queue engine's fact journal IS the journal since S2, so system's own event adapter stays unused (no second source of truth; the split-brain gate of the archived composition map §3).

What the System owns here (the map's sanctioned shape):

  • the projection-home engine (deployment decision, one DeploymentConfig place: swap sqlite -> postgres by editing Engines, never domain code);
  • close ordering for the surfaces that adopt it (GracefulClose after the runactor actors stop — serve today, per §4c "adopt per surface");
  • the growth seam: timers (§4a ruled: sweeper ticking STAYS runactor until a genuinely timer-shaped feature lands), deciders, and system.Lookup/metaengine query declarations attach to THIS root.

What it deliberately does NOT own: the tq queue.Store (S1's thin-driver seam, injected as today), the worker claim loops, the sweepers, and the readmodel's fold projector (a tq-side projection over the QUEUE journal; its collections live on the same projection-home file through their own metaengine Plan).

Index

Constants

View Source
const DefaultEngineName = "projections"

DefaultEngineName is the projection-home engine's deployment name.

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, dbPath string) (*system.System, error)

New composes the system root for one queue database. dbPath is the QUEUE database path (the projection home is derived beside it).

Types

type ProjectionRuntime added in v0.3.4

type ProjectionRuntime struct {
	Model *readmodel.Model
	Host  *readmodel.ProjectionHost
	// contains filtered or unexported fields
}

ProjectionRuntime bundles the ADR-0019 S3 fold surfaces one serve run owns: the model, the poison-fact sidecar (nil when it could not be opened — warn-and-continue), and the managed projection host. Close tears them down in LIFO order (host stop+close, sidecar, model), the ordering the serve wiring previously hand-rolled with stacked defers.

func NewProjectionRuntime added in v0.3.4

func NewProjectionRuntime(ctx context.Context, src queue.Store, modelPath string) (*ProjectionRuntime, error)

NewProjectionRuntime composes the projection runtime for the projection home at modelPath over the queue journal (src): open the model with a durable cursor, best-effort the DLQ sidecar beside it, and build the managed host wired with the sidecar. Starting stays the caller's job (Host.Start) so the runactor actor keeps its own lifecycle; on a build error nothing is left open.

func (*ProjectionRuntime) Close added in v0.3.4

func (r *ProjectionRuntime) Close() error

Close releases the runtime in reverse construction order: host stop and close, then the DLQ sidecar, then the model. Safe to call once; the serve wiring defers it exactly where its stacked defers used to live.

Jump to

Keyboard shortcuts

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