Skip to content

Hot reload / reloadable config #138

Description

@Niccolum

Motivation:
The comment in loading/loader.py explicitly defers watchers/polling to the future.
A TTL-based cache exists (loading/cache.py) but does not actively push updates.
Long-running services need to pick up config changes without restarting.

Proposal:
ReloadableConfig wrapper over load():

  • get_latest() → T — always returns the most recently loaded instance (immutable,
    no mutation of the previous object, matching hoplite's philosophy).
  • subscribe(callback: Callable[[T], None]) — notified after each successful reload.
  • Triggers:
    • FixedIntervalTrigger(seconds=N) — background thread polls every N seconds.
    • FileWatchTrigger(paths=...) — OS-level file watch (optional dependency, e.g.
      watchdog) behind an extras group; graceful degradation to polling if missing.
  • Reload errors do not replace the current config; they are passed to an optional
    on_error callback.

This is a large feature; consider splitting into two PRs (interval-only first, then
file-watch).

Acceptance criteria:

  • Interval trigger reloads on schedule; get_latest() returns new instance.
  • Subscriber callback receives the new instance.
  • A reload error keeps the old instance; on_error is called.
  • File-watch trigger works when watchdog is installed; falls back gracefully.
  • Tests for interval + error-handling paths; file-watch tested with mock.
  • changes/ fragment.

References: hoplite hoplite-watch, ReloadableConfig, FixedIntervalWatchable,
FileWatcher.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions