Skip to content

[Feature] resolveSettings helper for DRY settings-merge boilerplate #255

Description

@pathosDev

Size / Priority

Affected files

Background

This is the general-purpose version of #248. The broker-specific helper in #248 is one application; the framework has at least:

  • Broker settings (8 brokers).
  • Cache settings (3 caches).
  • Journal settings (3 journals).
  • Cluster settings.
  • HTTP backend settings.

All do similar three-source merging. A single typed helper:

// src/util/Settings.ts (new)

export function applyDefaults<S extends Record<string, unknown>>(
  partial: Partial<S>,
  defaults: S,
): S;

export function resolveSettings<S extends Record<string, unknown>>(
  defaults: S,
  configKey: string,
  configObj: Config,
  ctorArgs?: Partial<S>,
): S;

applyDefaults is the simple "missing fields filled in" case; resolveSettings is the three-source version (delegate to applyDefaults for the merging logic).

Coordination

This issue is largely the umbrella for both (and a few more sites — cache, journal, cluster settings). Coordinated implementation.

Integration / risk

  • No behavioural change.
  • Migrate site-by-site.

Test plan

  1. Per-site regression — each settings consumer behaves identically.
  2. Edge cases — empty config, partial config, missing keys fall through to defaults.

Acceptance criteria

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpriority: lowNice-to-have / niche / demand-driven

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions