feat: Add a shared file data reloader, poller, and watcher - #361
Draft
kinyoklion wants to merge 1 commit into
Draft
kinyoklion wants to merge 1 commit into
kinyoklion wants to merge 1 commit into
Conversation
Adds the Internal/FileLoading namespace with the file reading code that the flag overrides feature needs: a document parser and merger that keep each entry's own version and report per-document counts, a reloader that serializes reloads, debounces change signals, retains the last good result on failure, retries after a bounded delay, reports an identical repeated failure once, and skips unchanged content, a stat-based poller, and a directory watcher that handles files that do not exist yet. The existing file data source keeps its current behavior and does not use the shared code. Tests that pin that behavior are added so later changes to the shared code cannot alter it.
kinyoklion
force-pushed
the
rlamb/overrides-dotnet-filedata-reloader
branch
from
September 28, 2026 20:39
883fd4b to
353e748
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is the first of the file-based flag overrides changes for the server SDK, as defined by the OVERRIDE specification. The override source that a later change adds needs file reading code with the reliability the specification requires of a source that operators edit during an incident: a reload that keeps the last good data when a file is unreadable or malformed, a retry after such a failure that does not wait for another change notification, coalescing of the burst of notifications that one edit produces, a file that does not exist yet contributing no data, and a change detector that does not depend on notification delivery.
The new
Internal/FileLoadingnamespace holds that code. It is purely additive: nothing in the SDK uses it yet, and the existing file data source keeps its current behavior.FileDataParserparses the file data document format (flags,flagValues,segments) into aFileDataDocument, keeping each entry's own version, with the same optional alternate parser for non-JSON content as the file data source.MakeOffFlagWithValueexpands aflagValuesentry into a flag that is off and serves its single value, which is the form the override source uses.FileDataMergercombines documents in configured order withFailorIgnoreduplicate keys handling and reports how many entries it kept from each document.FileDataReloaderowns the reload cycle: it serializes reloads, debounces change signals with a settle window that each signal extends, retains the last good result on failure by not applying anything, retries a failed reload after a bounded delay, reports an identical repeated failure once, skips a reload whose raw contents are unchanged, and optionally treats a missing file as a file with no content. Dispose never waits for an in-flight reload.FileDataPollerdetects changes by examining each file's modification time, size, and existence on a fixed interval.FileDataWatcherdetects changes throughFileSystemWatcheron each file's directory, so a file that appears later or is deleted is reported.FileDataSource,FlagFileParser, and the file data source builder are unchanged, and their existing tests are unchanged.FileDataSourceExistingBehaviorTestadds tests that pin behavior of the file data source that its existing tests did not assert directly, so that later changes to the shared code cannot alter it: every successful load is applied even when the content is unchanged, the 600 ms retry delay and its warning on every failed attempt, the log messages and levels for a failed load, a path in a missing directory being a failure even withSkipMissingPaths, and a deleted file producing no reload.Every new component has unit tests, including the debounce settle window, retry without further signals, last-good retention and recovery, serialized reloads, and non-blocking dispose. No public API changes.