Skip to content

feat: Add debounce, retry, and last-good retention to file data loading - #220

Draft
kinyoklion wants to merge 1 commit into
feat/overridesfrom
rlamb/overrides-java-filedata-reloader
Draft

kinyoklion wants to merge 1 commit into
feat/overridesfrom
rlamb/overrides-java-filedata-reloader

Conversation

@kinyoklion

Copy link
Copy Markdown
Member

Summary

The flag overrides feature defined by the OVERRIDE specification needs a file-based override source that reloads reliably: coalesced change notifications, retry after a failed read, retention of the last good data, sequential reloads, and support for files that do not exist yet. The existing file data source reloaded on every file system event with no debounce or retry, and any missing file failed the whole load.

This change adds the shared file infrastructure that both the file data source and the upcoming override source use, in the integrations package:

  • FileDataReloader serializes reloads, debounces change signals with a 100 ms settle window, keeps the last good data on failure by not applying, retries a failed load after one second, reports an identical repeated failure once, and skips a reload whose raw content did not change. Close never waits for an in-flight read.
  • FileDataPoller detects changes by examining each file's modification time and size on a fixed interval, including a file that appears or disappears.
  • FileDataWatcher is the WatchService-based watcher extracted from FileSynchronizer, with one extra signal after start so a change made between the initial load and the start of watching is not missed.
  • DataLoader gains options to skip a file path that does not exist and to keep the versions that a document specifies, a per-source summary of what each file supplied, and a content digest for the skip-unchanged check. A document that parses but holds flag data the model cannot accept is now reported as a file data error instead of escaping as a runtime exception.

FileSynchronizer now reloads through the reloader. The file data source keeps its behavior for existing users: every configured file must exist, entries get a load version, and a value-only entry is an on flag with a single fallthrough variation. FileDataException.getDescription no longer fails when the exception has no cause.

The file data source reloaded on every file system event with no debounce
or retry, and any missing file failed the load. The flag overrides feature
needs a file source that reloads reliably: coalesced change notifications,
retry after a failed read, retention of the last good data, sequential
reloads, and files that do not exist yet.

This adds the shared file infrastructure in the integrations package:

- FileDataReloader serializes reloads, debounces change signals, keeps the
  last good data on failure by not applying, retries a failed load after a
  bounded delay, reports an identical repeated failure once, and skips a
  reload whose raw content did not change. Close never waits for an
  in-flight read.
- FileDataPoller detects changes by examining each file's modification
  time and size on a fixed interval, including a file that appears or
  disappears.
- FileDataWatcher is the WatchService watcher extracted from
  FileSynchronizer, with one extra signal after start so a change between
  the initial load and the start of watching is not missed.
- DataLoader gains options to skip a file path that does not exist and to
  keep the versions that a document specifies, a per-source summary of
  what each file supplied, and a content digest for the skip-unchanged
  check.

FileSynchronizer now reloads through the reloader. The file data source
keeps its behavior for existing users: every configured file must exist,
entries get a load version, and a value-only entry is an on flag with a
single fallthrough variation. FileDataException.getDescription no longer
fails when the exception has no cause.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant