Multi-service boot: several services (each its own org) in one release, plus a singleton helper #8

Closed
opened 2026-12-02 06:00:00 +00:00 by saturnus · 1 comment
Member

Purpose (feature): one BEAM release hosts several mcl services, each in its own org, with one identity key, one mesh pool, one health socket and one claim per org, plus a singleton helper so a side effect runs on exactly one node of a cluster. This is the base the per-service packages (§2.5 step 3) and the clustered mcl-martha release build on.

Raf, 2026-12-02: "Run the whole path (Recommended)" — the crew runs the whole path to one clustered mcl-martha release, in order.
Raf, 2026-12-02: "trust on sight. mcl-martha services should auto-cluster over LAN, no mcl-station required. Distributed Erlang offers us all we need."

Refs martha-ai/mcl-martha#1 (consolidation plan §2.3 "mcl_om (L, first)", §2.5 step 2, A3 package 3).

The API the per-service packages build on

%% Unchanged: a standalone release keeps calling exactly this.
mcl_om:boot(ServiceMod) / mcl_om:boot(ServiceMod, Opts)
%% Each call now ADDS ServiceMod to the services this node hosts (a second
%% boot of the same module replaces only its own entry), so a bundle may call
%% it once per service, or once with the list:
mcl_om:boot([ServiceMod | {ServiceMod, Opts}]) ->
    {ok, [{ServiceMod, pid()}]} | {error, {ServiceMod, Reason}}

%% A service's org: the `org' key of its info/0 when present, else the
%% mcl_om `org' app env (today's behaviour, so nothing standalone changes).
info() -> #{name => ..., version => ..., description => ..., org => <<"mcl-kanban">>}

mcl_om:service_modules() -> [module()]   %% in boot order; service_module/0 stays (the first)

%% Singleton: a supervisor child that runs MFA on exactly one node of the
%% connected cluster, under a `global' name; the others stand by and take over
%% when the holder's node goes down. On a node without distribution it simply runs.
mcl_om_singleton:child_spec(Name, {M, F, A}) -> supervisor:child_spec()
mcl_om_singleton:whereis(Name) -> pid() | undefined

What changes inside mcl_om

  • Capabilities are kept per service (each under its own org) and merged; registering one service never replaces another's set (C1). Advertising, grants and liveness rows are per org procedure.
  • <org>/info, <org>/get_limits / set_limits and <service>.describe_capabilities answer for the service of that org, not "the" service.
  • Health combines every service's verdict; a failing one is named ({degraded | down, {ServiceName, Reason}} when more than one service is booted; one service keeps today's shape).
  • mcl_om_claim claims once per distinct org (today only mcl_om_identity:org(), mcl_om_claim.erl:247,256). /health's claim stays today's map for one org and is a list of those maps for several.
  • Still one identity key, one pool, one health socket.

Out

  • A3 package 7 (the claim follows a configured realm): io.macula stays.
  • Any service-side change (C2, C6-C9): those are the per-service packages.

Done when

  1. mcl_om:boot/1,2 with one service behaves as today: the existing eunit and CT suites pass unchanged.
  2. A test boots two services with different orgs in one VM: both orgs' capabilities are registered (neither replaces the other), /health combines both, and a failing service is named in the verdict.
  3. A test shows one claim per distinct org, and the claim health field for one org and for two.
  4. <org>/info and describe_capabilities answer for their own service when two are booted.
  5. mcl_om_singleton: a two-node test (peer nodes on loopback, no outside network) runs the child on exactly one node, and on the other once the holder's node stops.
  6. CHANGELOG under Unreleased names the new API.
Purpose (feature): one BEAM release hosts several mcl services, each in its own org, with one identity key, one mesh pool, one health socket and one claim per org, plus a singleton helper so a side effect runs on exactly one node of a cluster. This is the base the per-service packages (§2.5 step 3) and the clustered mcl-martha release build on. Raf, 2026-12-02: "Run the whole path (Recommended)" — the crew runs the whole path to one clustered mcl-martha release, in order. Raf, 2026-12-02: "trust on sight. mcl-martha services should auto-cluster over LAN, no mcl-station required. Distributed Erlang offers us all we need." Refs martha-ai/mcl-martha#1 (consolidation plan §2.3 "mcl_om (L, first)", §2.5 step 2, A3 package 3). ## The API the per-service packages build on ```erlang %% Unchanged: a standalone release keeps calling exactly this. mcl_om:boot(ServiceMod) / mcl_om:boot(ServiceMod, Opts) %% Each call now ADDS ServiceMod to the services this node hosts (a second %% boot of the same module replaces only its own entry), so a bundle may call %% it once per service, or once with the list: mcl_om:boot([ServiceMod | {ServiceMod, Opts}]) -> {ok, [{ServiceMod, pid()}]} | {error, {ServiceMod, Reason}} %% A service's org: the `org' key of its info/0 when present, else the %% mcl_om `org' app env (today's behaviour, so nothing standalone changes). info() -> #{name => ..., version => ..., description => ..., org => <<"mcl-kanban">>} mcl_om:service_modules() -> [module()] %% in boot order; service_module/0 stays (the first) %% Singleton: a supervisor child that runs MFA on exactly one node of the %% connected cluster, under a `global' name; the others stand by and take over %% when the holder's node goes down. On a node without distribution it simply runs. mcl_om_singleton:child_spec(Name, {M, F, A}) -> supervisor:child_spec() mcl_om_singleton:whereis(Name) -> pid() | undefined ``` ## What changes inside mcl_om - Capabilities are kept per service (each under its own org) and merged; registering one service never replaces another's set (C1). Advertising, grants and liveness rows are per org procedure. - `<org>/info`, `<org>/get_limits` / `set_limits` and `<service>.describe_capabilities` answer for the service of that org, not "the" service. - Health combines every service's verdict; a failing one is named (`{degraded | down, {ServiceName, Reason}}` when more than one service is booted; one service keeps today's shape). - `mcl_om_claim` claims once per distinct org (today only `mcl_om_identity:org()`, mcl_om_claim.erl:247,256). `/health`'s `claim` stays today's map for one org and is a list of those maps for several. - Still one identity key, one pool, one health socket. ## Out - A3 package 7 (the claim follows a configured realm): `io.macula` stays. - Any service-side change (C2, C6-C9): those are the per-service packages. ## Done when 1. `mcl_om:boot/1,2` with one service behaves as today: the existing eunit and CT suites pass unchanged. 2. A test boots two services with different orgs in one VM: both orgs' capabilities are registered (neither replaces the other), `/health` combines both, and a failing service is named in the verdict. 3. A test shows one claim per distinct org, and the `claim` health field for one org and for two. 4. `<org>/info` and `describe_capabilities` answer for their own service when two are booted. 5. `mcl_om_singleton`: a two-node test (peer nodes on loopback, no outside network) runs the child on exactly one node, and on the other once the holder's node stops. 6. CHANGELOG under Unreleased names the new API.
Author
Member

Landed: main a2aa62e3bd (PR 10; Jupiter r1 small FAIL fixed inline at 6869ac1, then the nit at a2aa62e).

Done when, checked against the landed range 2a15aef..a2aa62e:

  1. A single boot/1,2 behaves as before. The existing eunit and CT cases are unchanged and pass: eunit 475/0 (Jupiter, on 6869ac1); forge run 6564, job 26999 lint + eunit + ct, success on a2aa62e.
  2. Two services with different orgs in one VM: mcl_om_SUITE two_services_boot_in_one_vm, booting_a_service_again_replaces_only_its_own, health_names_the_failing_service, a_refused_start_in_a_list_names_the_service.
  3. One claim per distinct org, and claim for one org and for two: mcl_om_claim_tests one_claim_per_org_test_. A restarted worker claims again for every hosted org: restarted_worker_claims_every_hosted_org_test_ (Jupiter).
  4. <org>/info and describe_capabilities answer for their own service: info_answers_for_its_own_service, describe_answers_for_its_own_service.
  5. mcl_om_singleton on two peer nodes over loopback (mcl_om_singleton_SUITE): runs on exactly one node, the standby takes over when the holder's node stops, and two holders that meet keep one. {ok, Pid, Info} and ignore starts are covered too.
  6. CHANGELOG, Unreleased, Added: both entries.

Notes for the per-service packages (Jupiter, r1):

  • In a bundle, /health moves each service's name and version under services, and claim becomes a list.
  • During a netsplit the singleton runs one copy per connected partition (now in its moduledoc).

Accepted reds on the same runs: scaffold lint (#2), docs (#5).

Landed: main a2aa62e3bd2f4c231ff652a028fb67dfa5decb3c (PR 10; Jupiter r1 small FAIL fixed inline at 6869ac1, then the nit at a2aa62e). Done when, checked against the landed range 2a15aef..a2aa62e: 1. A single `boot/1,2` behaves as before. The existing eunit and CT cases are unchanged and pass: eunit 475/0 (Jupiter, on 6869ac1); forge run 6564, job 26999 `lint + eunit + ct`, success on a2aa62e. 2. Two services with different orgs in one VM: `mcl_om_SUITE` `two_services_boot_in_one_vm`, `booting_a_service_again_replaces_only_its_own`, `health_names_the_failing_service`, `a_refused_start_in_a_list_names_the_service`. 3. One claim per distinct org, and `claim` for one org and for two: `mcl_om_claim_tests` `one_claim_per_org_test_`. A restarted worker claims again for every hosted org: `restarted_worker_claims_every_hosted_org_test_` (Jupiter). 4. `<org>/info` and `describe_capabilities` answer for their own service: `info_answers_for_its_own_service`, `describe_answers_for_its_own_service`. 5. `mcl_om_singleton` on two peer nodes over loopback (`mcl_om_singleton_SUITE`): runs on exactly one node, the standby takes over when the holder's node stops, and two holders that meet keep one. `{ok, Pid, Info}` and `ignore` starts are covered too. 6. CHANGELOG, Unreleased, Added: both entries. Notes for the per-service packages (Jupiter, r1): - In a bundle, `/health` moves each service's name and version under `services`, and `claim` becomes a list. - During a netsplit the singleton runs one copy per connected partition (now in its moduledoc). Accepted reds on the same runs: scaffold lint (#2), docs (#5).
Commenting is not possible because the repository is archived.
No labels
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
macula-services/mcl-om#8
No description provided.