Skip to main content

Built and signed on GitHub Actions

Works with
This package works with DenoIt is unknown whether this package works with Cloudflare Workers, Node.js, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
•JSR Score100%•
License
Apache-2.0
•
Downloads97/wk
•
Publisheda day ago (0.0.10)

Hot-reloadable runtime overrides for NetScript services: load job, saga, trigger, feature-flag, and task overrides from a versioned config directory and reload them through a file watcher without restarting the process.

@netscript/runtime-config

JSR CI Docs

Hot-reloadable runtime overrides for NetScript services: load job, saga, trigger, feature-flag, and task overrides from a versioned config directory and reload them through a file watcher without restarting the process.

Project configuration (@netscript/config) is fixed at startup; runtime configuration is the layer operators change while the process runs — disable a misbehaving job, flip a feature flag, retune a trigger — without a deploy. loadRuntimeConfig() reads a versioned snapshot from the runtime config directory, every accessor resolves overrides against that typed snapshot, and watchRuntimeConfig() reloads it when deployment tooling writes a new version. Missing files resolve to empty defaults, so a service boots cleanly before any override exists.

Why teams use it

  • Versioned snapshot loading — loadRuntimeConfig() reads a current pointer file and resolves the active job, saga, trigger, feature-flag, and task override files for that version.
  • Empty-default startup — a missing runtime directory, pointer, or topic file yields empty defaults, so a service can boot before deployment tooling writes any overrides.
  • Debounced hot reload — watchRuntimeConfig() watches the config directory with Deno.watchFs and invokes a consumer callback after debounced reloads, cancellable through an AbortSignal.
  • Typed override accessors — getJobOverride, getSagaOverride, getTriggerOverride, getRuntimeTask, and isFeatureEnabled resolve overrides by ID against a typed RuntimeConfig snapshot.
  • Caller-owned diagnostics — summarizeRuntimeConfig() returns a structured RuntimeConfigSummary of active overrides without emitting any presentation output.

Architecture

flowchart LR
    T["Deployment tooling"] -- "writes version N+1<br/>+ current pointer" --> D["runtime config dir<br/>(versioned snapshots)"]
    D --> L["loadRuntimeConfig()"]
    L --> S["RuntimeConfig snapshot<br/>jobs · sagas · triggers · flags · tasks"]
    D -- "Deno.watchFs (debounced)" --> W["watchRuntimeConfig()"]
    W -- "reload" --> L
    S --> A["getJobOverride · isFeatureEnabled · ..."]

The write side is owned by deployment tooling: it drops a new versioned override set and flips the current pointer. The read side — this package — only ever loads, watches, and resolves; the consumer callback owns what happens on reload.

Install

deno add jsr:@netscript/runtime-config@<version>

Pin <version> to match your installed CLI; bare jsr:@netscript/* specifiers do not resolve on the pre-release line.

Quick example

import {
  getJobOverride,
  isFeatureEnabled,
  loadRuntimeConfig,
  summarizeRuntimeConfig,
  watchRuntimeConfig,
} from '@netscript/runtime-config';

// Load the active override snapshot. Missing files resolve to empty
// defaults, so startup never blocks on config.
const config = await loadRuntimeConfig();

// Feature flags fall back to the provided default when no override exists.
if (isFeatureEnabled(config, 'email-worker', true)) {
  const cleanup = getJobOverride(config, 'cleanup');
  if (cleanup?.enabled === false) {
    // A runtime override has disabled the scheduled cleanup job.
  }
}

// Reload when operators roll out new overrides; the callback owns reporting.
const controller = new AbortController();
watchRuntimeConfig(async (next) => {
  const summary = summarizeRuntimeConfig(next, '[runtime-config]');
  for (const message of summary.messages) console.info(message);
}, { signal: controller.signal });

Public surface

One entrypoint carries the package: the loader (loadRuntimeConfig), the watcher (watchRuntimeConfig), the typed accessors (getJobOverride, getSagaOverride, getTriggerOverride, getRuntimeTask, isFeatureEnabled), the diagnostics helper (summarizeRuntimeConfig), and the RuntimeConfig / override types with the RUNTIME_CONFIG_TOPICS and RUNTIME_TASK_RUNTIMES constants.

The always-current symbol list is deno doc jsr:@netscript/runtime-config@<version> (pin <version> on the pre-release line, as above).

Docs

Compatibility

Requires Deno 2+ — the loader needs --allow-read on the runtime config directory, and watchRuntimeConfig additionally uses Deno.watchFs. Node.js and Bun are not supported as runtimes for the watcher; the types are runtime-neutral.

License

Apache-2.0 — see LICENSE. Published to JSR with cryptographically verified provenance.

Examples

Example 1

import {
  isFeatureEnabled,
  loadRuntimeConfig,
  summarizeRuntimeConfig,
} from '@netscript/runtime-config';

declare function publishRuntimeStatus(status: { enabled: boolean; messages: string[] }): Promise<void>;

const config = await loadRuntimeConfig();
const enabled = isFeatureEnabled(config, 'worker-rollout', false);
const summary = summarizeRuntimeConfig(config);

await publishRuntimeStatus({ enabled, messages: summary.messages });
Built and signed on
GitHub Actions

Add Package

deno add jsr:@netscript/runtime-config

Import symbol

import * as runtime_config from "@netscript/runtime-config";
or

Import directly with a jsr specifier

import * as runtime_config from "jsr:@netscript/runtime-config@^0.0.10";