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.
Motivation:
The comment in
loading/loader.pyexplicitly 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:
ReloadableConfigwrapper overload():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.FixedIntervalTrigger(seconds=N)— background thread polls every N seconds.FileWatchTrigger(paths=...)— OS-level file watch (optional dependency, e.g.watchdog) behind anextrasgroup; graceful degradation to polling if missing.on_errorcallback.This is a large feature; consider splitting into two PRs (interval-only first, then
file-watch).
Acceptance criteria:
get_latest()returns new instance.on_erroris called.watchdogis installed; falls back gracefully.changes/fragment.References: hoplite
hoplite-watch,ReloadableConfig,FixedIntervalWatchable,FileWatcher.