Liking cljdoc? Tell your friends :D

hive-compose.pipeline.ops

Section and profile operations over a context:

{:engine IComposeEngine :runner IProgramRunner ; optional: host programs :settings Settings :state (atom {:active {id Active} :current id-or-nil}) :now (fn [] epoch-ms) :save! (fn [persisted-state] Result)} ; optional

A subject is a Profile: a configured preset (lookup) or a section resolved from a target against the configured compose projects (resolve-target). Every operation answers a Result (reap! and adopt! answer reports). The active map changes only after the engine confirmed the action.

A section also holds the host programs paired with its services: they start once its containers are up and stop when the last section holding them is released. A program that fails to start is reported, never fatal.

Section and profile operations over a context:

  {:engine   IComposeEngine
   :runner   IProgramRunner                   ; optional: host programs
   :settings Settings
   :state    (atom {:active {id Active} :current id-or-nil})
   :now      (fn [] epoch-ms)
   :save!    (fn [persisted-state] Result)}   ; optional

A subject is a Profile: a configured preset (`lookup`) or a section resolved
from a target against the configured compose projects (`resolve-target`).
Every operation answers a Result (reap! and adopt! answer reports). The
active map changes only after the engine confirmed the action.

A section also holds the host programs paired with its services: they start
once its containers are up and stop when the last section holding them is
released. A program that fails to start is reported, never fatal.
raw docstring

adopt!clj

(adopt! ctx)

Take charge, with a fresh idle clock, of what runs without an owner: configured presets that are running, and the running services of configured compose projects that no active profile accounts for (as section <project>/adopted, needing their depends_on closure). Configured projects that share one compose project adopt each stray once, in id order. Answers the adopted ids.

Take charge, with a fresh idle clock, of what runs without an owner:
configured presets that are running, and the running services of configured
compose projects that no active profile accounts for (as section
`<project>/adopted`, needing their depends_on closure). Configured projects
that share one compose project adopt each stray once, in id order. Answers
the adopted ids.
sourceraw docstring

adopt-profileclj

(adopt-profile ctx p)

{:profile Profile :assumed? bool}: what section p, found running but not tracked, is recorded as having been started from. The active section that holds its services says (its dir, files and env, through promote.target/effective-profile); with none, or holders that disagree, nothing is known and p is recorded as an assumption.

{:profile Profile :assumed? bool}: what section `p`, found running but not
tracked, is recorded as having been started from. The active section that
holds its services says (its dir, files and env, through
`promote.target/effective-profile`); with none, or holders that disagree,
nothing is known and `p` is recorded as an assumption.
sourceraw docstring

adopted-section?clj

(adopted-section? id)

True when id names the section adopt! keeps strays of a project in.

True when `id` names the section adopt! keeps strays of a project in.
sourceraw docstring

claim-callclj

(claim-call ctx p tgt id)

The effective-subject call of a claim on section p (as section-subject resolved it from target tgt / profile id): by id when p is active or a preset, else by the target, so a claim that starts or adopts it uses the inputs an up would.

The `effective-subject` call of a claim on section `p` (as
`section-subject` resolved it from target `tgt` / profile `id`): by id when
`p` is active or a preset, else by the target, so a claim that starts or
adopts it uses the inputs an up would.
sourceraw docstring

config-healthclj

(config-health ctx)

{project-id {:compose-project name :ok? bool :error ..}}: whether docker compose config accepts each configured project as configured now (its files and env; references rendered, never read). A missing required variable, a bad file or an absent overlay shows here.

{project-id {:compose-project name :ok? bool :error ..}}: whether `docker
compose config` accepts each configured project as configured now (its
files and env; references rendered, never read). A missing required
variable, a bad file or an absent overlay shows here.
sourceraw docstring

down!clj

(down! ctx id action)
source

down-profile!clj

(down-profile! ctx p action)

Take p down with action (:down removes containers, :stop keeps them; volumes are never touched). Services and programs another active profile needs stay up.

Take `p` down with `action` (:down removes containers, :stop keeps them;
volumes are never touched). Services and programs another active profile
needs stay up.
sourceraw docstring

drop-stale-call-env!clj

(drop-stale-call-env! ctx old)

After a reload from Settings old to the ones in ctx: in every active entry, forget the remembered call env keys whose DECLARED value (preset env, or the project env of a section) changed, since the edit is the newer intent (promote.target/stale-call-env-keys). Answers {id [key]} of what was dropped.

After a reload from Settings `old` to the ones in `ctx`: in every active
entry, forget the remembered call env keys whose DECLARED value (preset
env, or the project env of a section) changed, since the edit is the
newer intent (`promote.target/stale-call-env-keys`). Answers {id [key]}
of what was dropped.
sourceraw docstring

effective-subjectclj

(effective-subject ctx {:keys [target id env]})

Result<{:profile Profile :section holder-id-or-nil :holder-skipped ..}>: the subject of an engine-reaching call (up, switch, restart; claim's start) with the compose inputs it must run with, through promote.target/effective-profile:

  • id (profile=): the preset or active snapshot (lookup), its remembered call env re-applied under this call's env;
  • target, ACTIVE: its own snapshot is its holder (the dir, files and env it was created from, its remembered call env), unless its inputs are only assumed (an adoption nothing explained), when the active section holding its services decides as below;
  • target, not active: the section resolved from the project as configured now, re-addressed at the active section that holds the services it names (orphaned ones too: they still run that code), whose dir, files and env it then uses and whose id it records under :profile/inputs-from. A holder whose dir no longer exists is skipped (:holder-skipped names it). Holders that disagree are :compose/holders-disagree naming them; id beside a target names the one to use. Held by none: the project defaults. env is this call's env; a nil value forgets that var. :section names the holder the call ran from, nil when none.
Result<{:profile Profile :section holder-id-or-nil :holder-skipped ..}>:
the subject of an engine-reaching call (up, switch, restart; claim's start)
with the compose inputs it must run with, through
`promote.target/effective-profile`:
- `id` (profile=): the preset or active snapshot (`lookup`), its remembered
  call env re-applied under this call's `env`;
- `target`, ACTIVE: its own snapshot is its holder (the dir, files and env
  it was created from, its remembered call env), unless its inputs are
  only assumed (an adoption nothing explained), when the active section
  holding its services decides as below;
- `target`, not active: the section resolved from the project as configured
  now, re-addressed at the active section that holds the services it names
  (orphaned ones too: they still run that code), whose dir, files and env
  it then uses and whose id it records under :profile/inputs-from. A holder
  whose dir no longer exists is skipped (:holder-skipped names it). Holders
  that disagree are :compose/holders-disagree naming them; `id` beside a
  target names the one to use. Held by none: the project defaults.
`env` is this call's env; a nil value forgets that var. :section names the
holder the call ran from, nil when none.
sourceraw docstring

inputs-known!clj

(inputs-known! ctx id p)

A recreate of active entry id ran with Profile p: when its inputs were only assumed, they are now p's (its services kept), no longer assumed.

A recreate of active entry `id` ran with Profile `p`: when its inputs were
only assumed, they are now `p`'s (its services kept), no longer assumed.
sourceraw docstring

logsclj

(logs ctx id tail)
source

logs-profileclj

(logs-profile ctx p tail)

Result<{:out}>: the last tail log lines of p; touches it when active. A profile with no compose project has no container log to read and asks docker nothing: :compose/programs-only (its programs log under the log dir).

Result<{:out}>: the last `tail` log lines of `p`; touches it when active.
A profile with no compose project has no container log to read and asks
docker nothing: :compose/programs-only (its programs log under the log dir).
sourceraw docstring

lookupclj

(lookup ctx id)

Result<Profile> for id: the configured preset, else the snapshot an active entry (a preset or a section) ran with. The snapshot of a section whose project is still configured is re-based on the project as configured now, so a release that follows a restart interpolates the files it names with the variables they need. What the snapshot's env says wins over the project's. A configured preset that is active keeps the env a call gave it (:profile/call-env of its snapshot), so a later up, restart or reaper pass never falls back to weaker env.

Result<Profile> for `id`: the configured preset, else the snapshot an active
entry (a preset or a section) ran with. The snapshot of a section whose
project is still configured is re-based on the project as configured now, so
a release that follows a restart interpolates the files it names with the
variables they need. What the snapshot's env says wins over the project's.
A configured preset that is active keeps the env a call gave it
(:profile/call-env of its snapshot), so a later up, restart or reaper pass
never falls back to weaker env.
sourceraw docstring

merge-adoptedclj

(merge-adopted old e)

Active entry old with the newly adopted strays of entry e folded in; e itself when there is no old. Pure.

The :profile snapshot's :profile/services follows the merged :services: logs and ps address a section through that snapshot, so a stale one would keep naming the subset adopted first. An entry without :needs needs exactly its :services, so a merged :needs starts from whichever of the two old carries.

Active entry `old` with the newly adopted strays of entry `e` folded in;
`e` itself when there is no `old`. Pure.

The `:profile` snapshot's `:profile/services` follows the merged
`:services`: logs and ps address a section through that snapshot, so a
stale one would keep naming the subset adopted first. An entry without
`:needs` needs exactly its `:services`, so a merged `:needs` starts from
whichever of the two `old` carries.
sourceraw docstring

missing-variableclj

(missing-variable res)

The variable compose named in a required variable <name> is missing a value refusal, nil for any other result.

The variable compose named in a `required variable <name> is missing a
value` refusal, nil for any other result.
sourceraw docstring

program-rowclj

(program-row ctx run)

What is known of started program run right now: alive, and whether its nREPL answers. A port the program chose itself is read from its .nrepl-port. One whose process is gone is :status :exited, with its exit code when the runner kept it and the last lines of its log.

What is known of started program `run` right now: alive, and whether its
nREPL answers. A port the program chose itself is read from its .nrepl-port.
One whose process is gone is :status :exited, with its exit code when the
runner kept it and the last lines of its log.
sourceraw docstring

programsclj

(programs ctx)

Result<[row]>: every program the configured projects declare, as it would start (kind, command, nREPL port, the services it is paired with) and, when it runs, its pid and whether its nREPL answers.

Result<[row]>: every program the configured projects declare, as it would
start (kind, command, nREPL port, the services it is paired with) and, when
it runs, its pid and whether its nREPL answers.
sourceraw docstring

projectsclj

(projects ctx)

Result<[project]>: every compose project on the host, managed ones marked. :label-files are the files docker recorded when its containers were created. For a project a configured one runs as, :configured lists those with their :files as configured now, and :stale-files the label files no configured project of that name uses (a different checkout, an overlay since dropped); :files-match? false says the running containers were not created from the files configured now.

Result<[project]>: every compose project on the host, managed ones marked.
:label-files are the files docker recorded when its containers were
created. For a project a configured one runs as, :configured lists those
with their :files as configured now, and :stale-files the label files
no configured project of that name uses (a different checkout, an overlay
since dropped); :files-match? false says the running containers were not
created from the files configured now.
sourceraw docstring

psclj

(ps ctx id)
source

ps-profileclj

(ps-profile ctx p)

Result<{:profile :needs :running}> for p; touches it when active. A profile with no compose project needs and runs no service.

Result<{:profile :needs :running}> for `p`; touches it when active. A
profile with no compose project needs and runs no service.
sourceraw docstring

reap!clj

(reap! ctx)

One reaper pass: reconcile, then release every idle profile. Each section answers its own row: one that cannot be released (an unset variable, a throw) is reported with why and the rest are still reaped.

One reaper pass: reconcile, then release every idle profile. Each section
answers its own row: one that cannot be released (an unset variable, a
throw) is reported with why and the rest are still reaped.
sourceraw docstring

rebase-sections!clj

(rebase-sections! ctx old-projects)

After the configured projects changed from old-projects to the ones in ctx's settings, re-base the snapshot of every active section of a changed project on its project as configured now, so a release, ps or logs by id runs with the new files and env. Answers {:rebased [id] :kept [{:id :reason}]}; a section whose project left the config keeps the snapshot it ran with.

After the configured projects changed from `old-projects` to the ones in
`ctx`'s settings, re-base the snapshot of every active section of a changed
project on its project as configured now, so a release, ps or logs by id
runs with the new files and env. Answers {:rebased [id] :kept [{:id :reason}]};
a section whose project left the config keeps the snapshot it ran with.
sourceraw docstring

reconcile!clj

(reconcile! ctx)

Forget active profiles none of whose services still run (taken down outside the addon), stopping the programs they alone hold. Answers the forgotten ids.

Forget active profiles none of whose services still run (taken down outside
the addon), stopping the programs they alone hold. Answers the forgotten ids.
sourceraw docstring

remember-call-env!clj

(remember-call-env! ctx id env)

Active entry id remembers call env env (a nil value forgets that var), as after an up: what a recreate ran with is what the section runs with. Nothing when id is not active or env is empty.

Active entry `id` remembers call env `env` (a nil value forgets that var),
as after an up: what a recreate ran with is what the section runs with.
Nothing when `id` is not active or `env` is empty.
sourceraw docstring

required-closureclj

(required-closure graph roots running)

What roots need under the depends_on edges of graph ({service {dep {:required? bool}}}): {:start [service]} follows only the required edges (an edge without :required? is required); {:needs [service]} adds the required: false dependencies met on the way that are already in running, together with everything those require in turn (and the running optional ones they meet), so release never strands a kept service. What :needs adds is waited on and kept, never started. Pure.

What `roots` need under the depends_on edges of `graph`
({service {dep {:required? bool}}}): {:start [service]} follows only the
required edges (an edge without :required? is required); {:needs [service]}
adds the `required: false` dependencies met on the way that are already in
`running`, together with everything those require in turn (and the running
optional ones they meet), so release never strands a kept service. What
:needs adds is waited on and kept, never started. Pure.
sourceraw docstring

resolve-targetclj

(resolve-target ctx target-str)
(resolve-target ctx target-str env)

Result<Profile>: the section running exactly what target-str names (services or native compose profiles, see promote.target/parse), in the first configured project that defines all of them. Its services close over the compose file's depends_on when brought up. env, the call's own, is given to the compose queries that resolve the target, so a variable the YAML requires can come from the call.

Result<Profile>: the section running exactly what `target-str` names
(services or native compose profiles, see `promote.target/parse`), in the
first configured project that defines all of them. Its services close over
the compose file's depends_on when brought up. `env`, the call's own, is
given to the compose queries that resolve the target, so a variable the
YAML requires can come from the call.
sourceraw docstring

runnerclj

(runner ctx)

The program runner, nil when the context has none or programs are off.

The program runner, nil when the context has none or programs are off.
sourceraw docstring

section-subjectclj

(section-subject ctx {:keys [target] :as call})

Result<Profile> for claim and release, which name a section that usually runs already: target is first an ACTIVE section id (flow-payment, dc/api), then a preset id, and only then a target resolved as subject does (services or native profiles). id (profile=) works as in subject. So claim target=flow-payment finds the preset section the way claim profile=flow-payment does, instead of asking compose for a service of that name.

Result<Profile> for claim and release, which name a section that usually
runs already: `target` is first an ACTIVE section id (flow-payment,
dc/api), then a preset id, and only then a target resolved as `subject`
does (services or native profiles). `id` (profile=) works as in
`subject`. So `claim target=flow-payment` finds the preset section the
way `claim profile=flow-payment` does, instead of asking compose for a
service of that name.
sourceraw docstring

start-section-programs!clj

(start-section-programs! ctx p services)

{:held {program-id Running} :report [..]}: start the host programs p pairs with services, reusing the live ones its project's sections hold. Host only: nothing is asked of the engine. For a section taken as it runs (a claim's adopt), which never goes through bring-up!.

{:held {program-id Running} :report [..]}: start the host programs `p`
pairs with `services`, reusing the live ones its project's sections hold.
Host only: nothing is asked of the engine. For a section taken as it runs
(a claim's adopt), which never goes through `bring-up!`.
sourceraw docstring

statusclj

(status ctx)

Every configured preset and every active section, with activity, reaper countdown and the host programs it holds. Up front, :ok? and :config say whether compose accepts each configured project now; a row of a project it rejects carries :config-ok? false, and an active one :reap-blocked? true, since no compose call on that project, the reaper's included, can run.

Every configured preset and every active section, with activity, reaper
countdown and the host programs it holds. Up front, :ok? and :config say
whether compose accepts each configured project now; a row of a project it
rejects carries :config-ok? false, and an active one :reap-blocked? true,
since no compose call on that project, the reaper's included, can run.
sourceraw docstring

subjectclj

(subject ctx {:keys [target id env]})

Result<Profile> for a tool call: target resolves a section, else id looks up a preset or an active section. A target is resolved against the config as it is now, so an active section picks up what its project gained since (a program, a TTL); the snapshot it ran with answers only when the target no longer resolves. env is the call's env, used by the compose queries that resolve the target.

Result<Profile> for a tool call: `target` resolves a section, else `id`
looks up a preset or an active section. A target is resolved against the
config as it is now, so an active section picks up what its project gained
since (a program, a TTL); the snapshot it ran with answers only when the
target no longer resolves. `env` is the call's env, used by the compose
queries that resolve the target.
sourceraw docstring

switch!clj

(switch! ctx id)
source

switch-profile!clj

(switch-profile! ctx p)

Make p current: release what only the previous current profile needs, then bring p up. Shared services and the programs p wants stay up throughout. Optional (required: false) dependencies are treated as in up-profile!.

Make `p` current: release what only the previous current profile needs, then
bring `p` up. Shared services and the programs `p` wants stay up throughout.
Optional (`required: false`) dependencies are treated as in `up-profile!`.
sourceraw docstring

targetsclj

(targets ctx)

Result<[{:project :services :profiles}]>: what can be named as a target in each configured compose project.

Result<[{:project :services :profiles}]>: what can be named as a target in each
configured compose project.
sourceraw docstring

touch!clj

(touch! ctx id)

Reset the idle clock of active profile id.

Reset the idle clock of active profile `id`.
sourceraw docstring

touch-all!clj

(touch-all! ctx project)

Reset the idle clock of every active profile, or only those of compose project project (the configured project id is accepted too).

Reset the idle clock of every active profile, or only those of compose
project `project` (the configured project id is accepted too).
sourceraw docstring

unknown-service-nameclj

(unknown-service-name res)

The service compose named in a no such service: <name> refusal, nil for any other result.

The service compose named in a `no such service: <name>` refusal, nil for
any other result.
sourceraw docstring

up!clj

(up! ctx id)
source

up-profile!clj

(up-profile! ctx p)

Bring p up alongside whatever is active. Becomes current when nothing is. A depends_on entry marked required: false is neither built nor started; it is only needed when already running. A profile with no compose project (program/up-mode :programs-only) asks compose nothing: it goes through the same bring-up with no service, so only its programs start.

Bring `p` up alongside whatever is active. Becomes current when nothing is.
A depends_on entry marked `required: false` is neither built nor started;
it is only needed when already running. A profile with no compose project
(`program/up-mode` :programs-only) asks compose nothing: it goes through
the same bring-up with no service, so only its programs start.
sourceraw docstring

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