Reloadable vs immutable
Some config is safe to change hot (rate limits, flags). Others aren't (DB connection strings). Mark reloadability at the schema level.
Advertisement
Reload trigger
configWatcher.on("application.yaml", (newCfg) -> {
if (newCfg.rateLimits() != current.rateLimits()) {
rateLimiter.updateLimits(newCfg.rateLimits());
}
// don't touch immutable fields
});Advertisement
Atomic swaps for related fields
Related config must swap together. Otherwise inconsistent state. Wrap in a compound update.