š Configuration refresh spec
How every Grimoire client (.NET, PHP, Node, Python) picks up configuration changes without a restart. The model follows Azure App Configurationās sentinel key: clients poll one small key and reload everything only when it changes. Every client follows this spec, so they all behave the same way (guibranco/grimoire-api#95).
Table of contents
Sentinel keys
| Key | Scope | Bumped by |
|---|---|---|
Sentinel |
One per application environment | Any change to that environmentās configuration or secret versions, or to the applicationās global inheritance |
Global:Sentinel |
One for all globals, stored at the * layer |
Any change to global configuration or global secret versions, whichever environment-slug layer it targets |
Both are ordinary configuration keys. Clients read them with the single-key endpoint, GET /consumer/configurations/{key}. They are left out of the configuration list, the export, environment diffs and dashboard counts. Their values are increasing numbers (Unix milliseconds), but clients only compare them for equality.
Applications that donāt inherit globals never see Global:Sentinel and get 404 for it. Clients treat that as āabsentā, not as an error.
Auto-publish
Grimoire decides when to bump a sentinel; clients donāt choose a mode:
- Auto-publish on (default): every change bumps the sentinel in the same transaction, so clients pick it up on their next check.
- Auto-publish off: the sentinel changes only when someone publishes (the UI āPublish changesā button or
POST ā¦/publish). Running clients then reload once, after the whole batch of edits, instead of after every edit.
Auto-publish controls when running clients reload, not what Grimoire serves. Edits are saved and served immediately. A process that starts, or a reload triggered by the other sentinel (for example a global publish), reads every saved value, including edits in an environment that hasnāt been published yet. Keep half-finished edits out of environments where that matters.
There is one setting per application environment and one for globals. Turning auto-publish back on publishes any pending changes. See Publishing.
Client algorithm
- Startup: load every value (
GET /consumer/configurations), then read each watched key once to record its value andETag. Recording a value never triggers a reload. - Every interval (default 30 s) plus 0ā20 % random jitter: send a conditional request for each watched key with
If-None-Match: <last ETag>.304: unchanged.200with the same value: unchanged (store the newETag).200with a different value, or a key that was absent and now exists, or one that existed and is now404: changed.
- On a change to a key watched with refresh all (both sentinels by default): fetch the full list, build a new dictionary and swap it in atomically. Never mutate the live dictionary in place. Then notify the application (reload token, event or callback).
- Secret cache: a client that caches secrets clears that cache when a sentinel changes. Secrets are fetched again lazily on the next read, not eagerly.
- On failure (network, HTTP 5xx, bad JSON): keep the last good values and back off exponentially (interval Ć 2āæ, at most 5 minutes). After the next success, go back to the normal interval. Never clear configuration because of a failed check.
- Shutdown: stop the timer and dispose the HTTP client.
Optional: a key watched without refresh all updates only that key (Azureās refreshAll: false).
Cost
An unchanged check is one request per watched key, each answered with 304 and no body. With the default two sentinels and a 30-second interval, thatās about 4 requests per minute per process.
Each poll counts as a consumer read for activity tracking, the same as feature-flag polling. The audit log records only failed sentinel reads (e.g. 404, rejected key); successful polls (200 or 304) of Sentinel and Global:Sentinel are not audited, so polling doesnāt flood it.
Clients
| Client | Status |
|---|---|
.NET Grimoire.Consumer |
AddGrimoire(o => o.Connect(ā¦).ConfigureRefresh()). See Configuration Provider |
PHP (Pancake GuiBranco\Pancake\Grimoire) |
guibranco/pancake#688 |
| Node | Planned (new package) |
| Python | Planned (new package) |