@@ -11,6 +11,8 @@ This package is a deliberately **lightweight wrapper of the Event-over-HTTP prot
1111 registered functions,
1212- a ** thin client** (` PostOffice ` ) to call functions on peer applications the same way,
1313- the ** standard event envelope wire format** codec (language-neutral MsgPack), and
14+ - a ** primitive in-process event bus** — the single dispatch pipeline: one FIFO mailbox
15+ per route consumed by ` instances ` worker loops, and
1416- the ** minimalist utilities** shared with the engines for consistency: configuration
1517 management, logging in the engines' presentation format, and distributed-trace context.
1618
@@ -43,7 +45,7 @@ Run it:
4345
4446``` bash
4547npm install && npm run build
46- node dist/src/cli.js app.mjs -- port 8087 # or: mercury-serve app.mjs -- port 8087
48+ node dist/src/cli.js app.mjs -Drest.server. port= 8087 # or: mercury-serve app.mjs -Drest.server. port= 8087
4749```
4850
4951Call it from a Mercury engine application with two configuration entries and no code —
@@ -78,6 +80,24 @@ status and reply headers). Node.js is non-blocking by nature; handlers may be as
7880- Functions must be stateless; anything you must keep belongs to the caller's flow model
7981 or state machine.
8082
83+ # ## Local function calls
84+
85+ ` PostOffice` **without an endpoint** delivers through this application's own event bus —
86+ the engines' semantics for an in-app `po` call :
87+
88+ - `isPrivate : true` means exactly what it means in the engines: callable **in-app only**.
89+ Local calls reach private and public routes alike; the HTTP host keeps answering 403
90+ for private targets from the wire.
91+ - `instances` is faithful : each route has one FIFO mailbox consumed by that many worker
92+ loops. RPC waits are bounded by `timeoutMs` (the standard 408 envelope on breach), and
93+ a queued call whose caller already timed out is skipped, never wastefully executed.
94+ - There is **no spill tier and no queue cap** by design : back-pressure belongs to the tier
95+ that owns recovery — the engines' flows and graphs. A leaf host fails fast by deadline
96+ instead of hoarding work.
97+
98+ Local eventing is for simple leaf-side composition. Workflow processing belongs in Event
99+ Script and Knowledge Graph on the engines — that boundary is the architecture.
100+
81101# # Configuration, logging, telemetry
82102
83103The same conventions as the engines, so a polyglot installation stays uniform :
@@ -86,12 +106,14 @@ The same conventions as the engines, so a polyglot installation stays uniform:
86106|-----|---------|---------|
87107| `application.name` | application identity in logs | `application` |
88108| `rest.server.port` | Event API port | `8085` |
89- | `log.format` | `text` or `json` | `text` |
109+ | `log.format` | `text`, `json` (pretty-printed) or `compact` (single-line JSONL) | `text` |
90110| `log.level` | log level (`LOG_LEVEL` env var wins) | `INFO` |
91111
92112Configuration lives in the `resources` folder, mirroring the engines :
93- ` resources/application.yml` (or `.yaml` / `.properties`), or an explicit `--config` path.
94- Values support `${ENV_VAR:default}` substitution. Runtime parameter overrides use the
113+ ` resources/application.yml` (or `.yaml` / `.properties`) in the working directory or next
114+ to the application file, or an explicit `--config` path — see
115+ [`examples/resources/application.yml`](examples/resources/application.yml) for a worked
116+ sample. Values support `${ENV_VAR:default}` substitution. Runtime parameter overrides use the
95117same `-D` syntax as the Java engine and the Rust port — checked first on every read
96118(`appConfig().set(key, value)` does the same programmatically, the `f:setConfig` analog) :
97119
@@ -105,6 +127,38 @@ Log lines follow the Java reference engine's pattern for one-aggregation consist
1051272026-08-22 10:15:30.123 INFO app:12 - Loaded PUBLIC hello.node, instances=10
106128` ` `
107129
130+ # # Actuator endpoints
131+
132+ The host serves the engines' operational endpoints on the same port as `/api/event`, so
133+ Kubernetes probes and dashboards treat a Node.js app exactly like a Java or Rust engine app :
134+
135+ | Endpoint | Purpose |
136+ |----------|---------|
137+ | `GET /info` | app identity, runtime, origin id, start time, uptime |
138+ | `GET /info/routes` | registered routes split by visibility, with instance counts |
139+ | `GET /env` | selected environment variables and configuration parameters |
140+ | `GET /health` | dependency health checks — `UP` (HTTP 200) or `DOWN` (HTTP 400) |
141+ | `GET /livenessprobe` | `OK` while the last health outcome was good, else HTTP 400 |
142+
143+ Configuration keys carry the engines' names : ` info.app.version` , `info.app.description`,
144+ ` show.env.variables` and `show.application.properties` (opt-in lists — secrets are never
145+ dumped wholesale), and `mandatory.health.dependencies` / `optional.health.dependencies`
146+ (routes of health check functions; optional ones never change the overall status). A
147+ health check function is a normal registered function — usually private — speaking the
148+ engines' interface contract, called through the event bus :
149+
150+ ` ` ` javascript
151+ preload('demo.health', { isPrivate: true }, async (headers, _body) => {
152+ if (headers.type === 'info') {
153+ return { service: 'demo.service', href: 'http://127.0.0.1' };
154+ }
155+ return 'demo.service is running fine'; // a non-200 reply marks it down
156+ });
157+ ` ` `
158+
159+ Kubernetes wiring : point `livenessProbe` at `/livenessprobe` and `readinessProbe` at
160+ ` /health` .
161+
108162# # Wire compatibility
109163
110164The codec implements the
@@ -120,10 +174,12 @@ millisecond precision; binary payloads are `Uint8Array`.
120174
121175# # Scope
122176
123- This package intentionally contains **no event bus, no flows, no graphs and no
124- orchestration** — those live in the engines. It provides functions plus the minimalist
125- foundation utilities, keeping Node.js fast to prototype with while the composable core
126- guarantees the architecture.
177+ This package intentionally contains **no orchestration : no flows, no graphs, no
178+ persistence, no pub/sub broadcast** — those live in the engines. What it does carry is
179+ deliberately minimal : functions, a primitive in-process event bus (route mailboxes +
180+ workers, RPC and drop-n-forget — nothing more), and the minimalist foundation utilities,
181+ keeping Node.js fast to prototype with while the composable core guarantees the
182+ architecture.
127183
128184# # License
129185
0 commit comments