Skip to main content

@hile/micro-dynamic-configs

Persist runtime config in Redis and publish typed changes through @hile/micro.

Choose This Package When

Use When

Use the message packages for request/response messaging over WebSocket, process IPC, worker threads, file-system message handlers, service discovery, streaming RPC, and registry-backed pub/sub.

Do Not Use When

  • Do not use stream() for normal single-result calls.
  • Do not rely on message IDs for business idempotency. They are transport IDs.
  • Do not bypass defineMessage() for file-loaded handlers.

Install

Use transport-specific packages only when you need to build custom IPC or worker-thread bridges.

Imports

Copy-Paste Example

Message handler file:
Microservice boot file:
Caller:

More Examples

Streaming handler:
Streaming caller:
Custom WebSocket modem:
Notice that request() returns a Promise<T>. Await it directly.

Runtime And Lifecycle Notes

  • MessageLoader maps *.msg.* files to routes using @hile/loader.
  • MessageLoader.dispatch(path, data, extras?) invokes the matched handler.
  • MessageModem._send() returns a Promise.
  • MessageModem._stream() returns a Node Readable in object mode.
  • A stream request requires exec() to return an async iterable.
  • Application.call(namespace, url, data, options?) returns a promise.
  • Application.stream(namespace, url, data, options?) returns a readable stream.
  • Application.publish(topic, payload) returns an object with update() and unpublish().
  • Application.subscribe(topic, callback) returns an unsubscribe function.
  • Registry stores service addresses and retained config/topic state under ~/.registry.

Anti-Patterns

  • Appending a secondary response getter to client.request('/x', data)
  • Returning a plain object from a handler called through stream().
  • Using pub/sub as a durable queue.
  • Forgetting to register shutdown(await app.listen(...)).

Verification Checklist

  • Message files default-export defineMessage(...).
  • RPC callers use await app.call(...).
  • Streaming handlers are async generators.
  • Registry is started before application nodes need discovery.
  • Micro apps use stable namespaces and advertise reachable hosts.

Runtime Dynamic Config

Complete Example

Package-Local AI Guide

This package also ships AI.md in npm so agents can read accurate examples after installation.