Skip to content

feat(internal): add stat-based file change poller - #407

Merged
kinyoklion merged 2 commits into
feat/overridesfrom
rlamb/sdk-2654/filedata-poller
Sep 18, 2026
Merged

kinyoklion merged 2 commits into
feat/overridesfrom
rlamb/sdk-2654/filedata-poller

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Jul 7, 2026

Copy link
Copy Markdown
Member

Adds a Poller to internal/filedata that detects file changes by examining modification time and size on a fixed interval. It exists for environments where file system notifications are unavailable or unreliable, such as network mounts, some containers, and Kubernetes ConfigMap symlink swaps. The file-based override source offers it as an alternative or a supplement to watching, and the file data sources can adopt it later.

A file that appears or disappears counts as a change. A file that os.Stat cannot examine counts as absent. The poller compares only modification time and size, so a rewrite that keeps both values is not detected. Detection is otherwise generous. The callback feeds a Reloader.Trigger, whose debouncing and skip-unchanged handling absorb spurious detections, so the poller itself stays small.

Close signals the poll loop and returns without waiting for an examination or callback in progress, matching the Reloader. A file system that does not respond must not block shutdown, so the callback can run once more shortly after Close returns. Consumers tolerate that as they do a late reload.

Internal only. Nothing in this PR consumes it.

SDK-2654


Note

Overview
Introduces a new Poller in internal/filedata that watches a list of paths on a fixed interval and invokes an onChange callback when os.Stat reports a different existence, modification time, or size. It is meant for setups where fsnotify-style watching is unreliable (e.g. network mounts, ConfigMap symlink swaps), with the intent to drive Reloader.Trigger later; nothing in this PR wires it up yet.

NewPoller snapshots state before returning so the first tick does not fire spuriously; Close stops the loop without waiting on in-flight stats or callbacks (same shutdown posture as Reloader), with tests covering multi-file watches, create/delete, and non-blocking close while a callback blocks.

Reviewed by Cursor Bugbot for commit 96068d8. Bugbot is set up for automated code reviews on this repo. Configure here.

@kinyoklion
kinyoklion requested a review from a team as a code owner July 7, 2026 21:23

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread internal/filedata/poller.go Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2365dd0. Configure here.

Comment thread internal/filedata/poller.go
Base automatically changed from rlamb/sdk-2654/filedata-reloader to v7 September 17, 2026 20:56
@kinyoklion
kinyoklion changed the base branch from v7 to feat/overrides September 17, 2026 21:18
…ogress

A file system that does not respond must not block shutdown. Close now signals the loop and returns, matching the Reloader, and the doc states that onChange can run once more shortly after Close. The doc uses ASCII, states that only modification time and size are compared, and drops the claim about temporarily unreadable files. Tests pin the Close contract, same-size and same-time changes, single firing per change, and changes to the first of several files.
@kinyoklion
kinyoklion force-pushed the rlamb/sdk-2654/filedata-poller branch from 1f4977e to 96068d8 Compare September 17, 2026 21:28
@kinyoklion
kinyoklion merged commit 6fb520a into feat/overrides Sep 18, 2026
26 checks passed
@kinyoklion
kinyoklion deleted the rlamb/sdk-2654/filedata-poller branch September 18, 2026 16:23
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.

2 participants