Liking cljdoc? Tell your friends :D

hive-compose.promote.data

Pure data lifecycle of a stack run (hc-9): seed, migrate and reset per capability, rendered as an ordered step list a pipeline runs.

A provider declares, beside its Provide (unqualified keys, an overlay on schema/Provide validated here, see ProvideData):

{:migrate DataCommand :seed DataCommand :reset DataCommand :reset-strategy :command|:template-db|:prefix-rotate :template {:user "postgres" :admin-db "postgres" :database-env "PGDATABASE"}}

A DataCommand is {:command [argv]} (a host process) or {:exec {:service svc :argv [..]}} (run inside the instance's container of svc), with optional :env and :timeout-ms.

Phases (lifecycle-plan): :before-suite migrate, then seed (template-db: into <tenant>_tpl, then CREATE DATABASE <tenant>_1 TEMPLATE <tenant>tpl). :between-suites reset: :command runs :reset then :seed; :template-db creates <tenant><n> from the template; :prefix-rotate moves the consumer to the next tenancy prefix and seeds it. :after :command runs :reset; the others change nothing.

Every step of a SHARED instance is scoped to one consumer's tenancy (its prefix is in the step env, :step/scope :tenancy): a shared instance is never reset as a whole. Volumes are never removed: a plan holding an argv that would (-v, --volumes, down -v, volume rm|prune) is refused. Secret references in :env stay references; a pipeline reads them at spawn.

Pure data lifecycle of a stack run (hc-9): seed, migrate and reset per
capability, rendered as an ordered step list a pipeline runs.

A provider declares, beside its Provide (unqualified keys, an overlay on
schema/Provide validated here, see `ProvideData`):

  {:migrate DataCommand :seed DataCommand :reset DataCommand
   :reset-strategy :command|:template-db|:prefix-rotate
   :template {:user "postgres" :admin-db "postgres" :database-env "PGDATABASE"}}

A DataCommand is {:command [argv]} (a host process) or {:exec {:service svc
:argv [..]}} (run inside the instance's container of `svc`), with optional
:env and :timeout-ms.

Phases (`lifecycle-plan`):
  :before-suite    migrate, then seed (template-db: into <tenant>_tpl, then
                   CREATE DATABASE <tenant>_1 TEMPLATE <tenant>_tpl).
  :between-suites  reset: :command runs :reset then :seed; :template-db
                   creates <tenant>_<n> from the template; :prefix-rotate
                   moves the consumer to the next tenancy prefix and seeds it.
  :after           :command runs :reset; the others change nothing.

Every step of a SHARED instance is scoped to one consumer's tenancy (its
prefix is in the step env, `:step/scope :tenancy`): a shared instance is
never reset as a whole. Volumes are never removed: a plan holding an argv
that would (`-v`, `--volumes`, `down -v`, `volume rm|prune`) is refused.
Secret references in :env stay references; a pipeline reads them at spawn.
raw docstring

Argvclj

source

create-database-sqlclj

(create-database-sql tenant generation)

CREATE DATABASE <tenant>_<n> TEMPLATE <tenant>_tpl.

CREATE DATABASE <tenant>_<n> TEMPLATE <tenant>_tpl.
sourceraw docstring

create-template-sqlclj

(create-template-sql tenant)
source

DataCommandclj

One data command: a host :command argv or an :exec inside a service of the instance, exactly one of them.

One data command: a host `:command` argv or an `:exec` inside a service of
the instance, exactly one of them.
sourceraw docstring

DataStateclj

What the lifecycle of a run has done so far: the generation each consumer is at on each instance (0 before any reset). A pipeline keeps it per run.

What the lifecycle of a run has done so far: the generation each consumer
is at on each instance (0 before any reset). A pipeline keeps it per run.
sourceraw docstring

generationclj

(generation state iid consumer)

The generation consumer is at on instance iid in state.

The generation `consumer` is at on instance `iid` in `state`.
sourceraw docstring

generation-databaseclj

(generation-database tenant generation)

The database a consumer uses at generation: <tenant>_<generation+1>.

The database a consumer uses at `generation`: `<tenant>_<generation+1>`.
sourceraw docstring

lifecycle-planclj

(lifecycle-plan settings sp phase)
(lifecycle-plan settings sp phase state)

Result<{:phase :run :steps [Step] :state DataState}> of StackPlan sp in phase (:before-suite :between-suites :after), from data state (what earlier phases of the run did, {} at first). Pure and deterministic: the same arguments always answer the same plan. Pairs (instance, consumer) run in the stack's start order; within a pair migrate precedes seed. :state is the state once the steps have run (generations advanced by a reset).

Result<{:phase :run :steps [Step] :state DataState}> of StackPlan `sp` in
`phase` (:before-suite :between-suites :after), from data `state` (what
earlier phases of the run did, {} at first). Pure and deterministic: the
same arguments always answer the same plan. Pairs (instance, consumer) run
in the stack's start order; within a pair migrate precedes seed. `:state`
is the state once the steps have run (generations advanced by a reset).
sourceraw docstring

next-prefixclj

(next-prefix run consumer prefix)

The prefix that follows prefix for consumer in run: one generation on. A prefix that is not theirs restarts at generation 1.

The prefix that follows `prefix` for `consumer` in `run`: one generation
on. A prefix that is not theirs restarts at generation 1.
sourceraw docstring

pairsclj

(pairs settings sp)

Result<[{:instance ip :consumer c :data pd :tenancy-var var}]>: every consumer bound to an instance whose Provide declares a data lifecycle, in the stack's start order of instances, then by consumer. An instance a consumer itself provides is its own business and left out.

Result<[{:instance ip :consumer c :data pd :tenancy-var var}]>: every
consumer bound to an instance whose Provide declares a data lifecycle, in
the stack's start order of instances, then by consumer. An instance a
consumer itself provides is its own business and left out.
sourceraw docstring

Phaseclj

source

phasesclj

source

prefix-generationclj

(prefix-generation run consumer prefix)

The generation prefix is at for consumer in run (inverse of rotated-prefix), nil when it is not one of theirs.

The generation `prefix` is at for `consumer` in `run` (inverse of
`rotated-prefix`), nil when it is not one of theirs.
sourceraw docstring

provide-dataclj

(provide-data settings provider capability)

Result<ProvideData|nil> of the Provide of capability by project provider in settings: nil when it declares no data lifecycle. Any declared command that would remove a volume is refused, whichever phase would run it.

Result<ProvideData|nil> of the Provide of `capability` by project
`provider` in `settings`: nil when it declares no data lifecycle. Any
declared command that would remove a volume is refused, whichever phase
would run it.
sourceraw docstring

ProvideDataclj

The data keys of a Provide. All optional: a Provide without them has no data lifecycle.

The data keys of a Provide. All optional: a Provide without them has no
data lifecycle.
sourceraw docstring

psql-argvclj

(psql-argv {:keys [user admin-db] :or {user "postgres" admin-db "postgres"}}
           sql)

psql running sql as user against admin-db, stopping on the first error. --set= rather than -v: no step carries -v.

psql running `sql` as `user` against `admin-db`, stopping on the first
error. `--set=` rather than `-v`: no step carries `-v`.
sourceraw docstring

removes-volumes?clj

(removes-volumes? argv)

True when argv could remove or recreate a volume, refusing when in doubt. Every argument is split on whitespace first, so a command wrapped in a shell (sh -c "docker compose down -v") or joined into one string is read as the words it runs. Refused anywhere in those words: -v, --volumes (--volumes=..), -V, --renew-anon-volumes, a short-flag cluster holding v or V beside down/rm/up/prune (down -fv), volume rm|remove|prune, system prune; and a shell -c script naming volume or prune at all. A script the argv only names (./seed.sh) cannot be read, so its contents are never checked: it is the provider's to keep volume-safe. psql steps use --set=, never -v.

True when `argv` could remove or recreate a volume, refusing when in doubt.
Every argument is split on whitespace first, so a command wrapped in a shell
(`sh -c "docker compose down -v"`) or joined into one string is read as
the words it runs. Refused anywhere in those words: `-v`, `--volumes`
(`--volumes=..`), `-V`, `--renew-anon-volumes`, a short-flag cluster
holding `v` or `V` beside `down`/`rm`/`up`/`prune` (`down -fv`), `volume
rm|remove|prune`, `system prune`; and a shell `-c` script naming `volume`
or `prune` at all. A script the argv only names (`./seed.sh`) cannot be
read, so its contents are never checked: it is the provider's to keep
volume-safe. psql steps use `--set=`, never `-v`.
sourceraw docstring

ResetStrategyclj

source

rotated-prefixclj

(rotated-prefix run consumer generation)

The tenancy prefix of consumer in run at generation: generation 0 is the wiring's prefix <run>.<consumer>. (names/tenancy-prefix), generation n > 0 is <run>.<consumer>.g<n>.. Distinct per generation, and every one starts with the consumer's base prefix, so ACLs on the base still hold.

The tenancy prefix of `consumer` in `run` at `generation`: generation 0 is
the wiring's prefix `<run>.<consumer>.` (names/tenancy-prefix), generation
n > 0 is `<run>.<consumer>.g<n>.`. Distinct per generation, and every one
starts with the consumer's base prefix, so ACLs on the base still hold.
sourceraw docstring

Stepclj

One rendered step. :step/target :exec runs :step/argv in the container of :step/service under compose project :step/compose-project; :host runs it on the host; :state has no argv (a prefix rotation: the pipeline records :step/prefix). :step/tolerate is stderr text that makes a failure count as done (an existing template database).

One rendered step. `:step/target` :exec runs `:step/argv` in the container
of `:step/service` under compose project `:step/compose-project`; :host
runs it on the host; :state has no argv (a prefix rotation: the pipeline
records `:step/prefix`). `:step/tolerate` is stderr text that makes a
failure count as done (an existing template database).
sourceraw docstring

strategyclj

(strategy pd)

The reset strategy of a ProvideData: the declared one, else :command when it has a :reset, else nil (no reset).

The reset strategy of a ProvideData: the declared one, else :command when
it has a :reset, else nil (no reset).
sourceraw docstring

Templateclj

Postgres template settings: the role psql runs as, the database it connects to for CREATE DATABASE, and the env var a consumer reads its database name from.

Postgres template settings: the role psql runs as, the database it
connects to for CREATE DATABASE, and the env var a consumer reads its
database name from.
sourceraw docstring

template-databaseclj

(template-database tenant)
source

tenant-databaseclj

(tenant-database run consumer)

Postgres database base name of consumer in run: <run>_<consumer>, only [a-z0-9_], kept within 50 chars (63 is Postgres' limit, and _tpl or _<n> follow) by a stable hash suffix.

Postgres database base name of `consumer` in `run`: `<run>_<consumer>`,
only [a-z0-9_], kept within 50 chars (63 is Postgres' limit, and `_tpl` or
`_<n>` follow) by a stable hash suffix.
sourceraw docstring

tenant-database-varclj

source

tenant-prefix-varclj

source

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close