-
Notifications
You must be signed in to change notification settings - Fork 45
chore: Support file data source as initializer and synchronizer #371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| new_times = self._check_file_times() | ||
| changed = False | ||
| for file_path, file_time in self._file_times.items(): | ||
| if new_times.get(file_path) is not None and new_times.get(file_path) != file_time: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Polling Misses Inaccessible File Changes
The polling mechanism doesn't detect when a previously accessible file becomes inaccessible. The condition new_times.get(file_path) is not None prevents detecting changes when a file's modification time changes from a valid timestamp to None. This means if a file is deleted or becomes unreadable, the synchronizer won't reload and report an error until the file becomes accessible again or another file changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is how the existing implementation works, but dependence on file modification timestamp precision isn't amazing.
| try: | ||
| ret[path] = os.path.getmtime(path) | ||
| except Exception: | ||
| ret[path] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need any log for this situation?
54cbdff to
c0570e2
Compare
Note
Add FDv2 file-based data source implementing Initializer/Synchronizer with auto-update and expose via Files.new_data_source_v2, plus comprehensive tests.
ldclient/impl/integrations/files/file_data_sourcev2.pyimplementing_FileDataSourceV2as both an Initializer (fetch) and Synchronizer (sync) using local files.TRANSFER_FULLChangeSetwithSelector.no_selector()fromflags,flagValues, andsegments(JSON/YAML), ensuring versions and duplicate-key checks._WatchdogAutoUpdaterV2or polling_PollingAutoUpdaterV2withRepeatingTask; emitsUpdatewithVALIDorINTERRUPTEDstates;stop()to clean up.Files.new_data_source_v2(paths, poll_interval, force_polling)returning a builder for FDv2 data system usage; update imports and typing.ldclient/testing/integrations/test_file_data_sourcev2.pycovering initializer and synchronizer (initial load, YAML, multiple files, duplicates, invalid data, file change detection, stop behavior, single-path handling).Written by Cursor Bugbot for commit 5d483f6. This will update automatically on new commits. Configure here.