Skip to content

feat: added Client.watch_snapshot for real-time snapshot monitoring#38

Merged
petruki merged 9 commits intomasterfrom
staging
Mar 9, 2026
Merged

feat: added Client.watch_snapshot for real-time snapshot monitoring#38
petruki merged 9 commits intomasterfrom
staging

Conversation

@petruki
Copy link
Member

@petruki petruki commented Mar 8, 2026

This pull request introduces snapshot file monitoring to the Switcher client, allowing the system to automatically detect and handle changes to the snapshot file in real time. The main changes include implementing the snapshot watcher logic, integrating it into the client API, updating documentation and playground use cases, and adding comprehensive tests for the new feature.

Snapshot monitoring feature:

  • Added the SnapshotWatcher class to switcher_client/lib/snapshot_watcher.py, which uses a background thread to poll the snapshot file for changes and reloads the snapshot when modifications are detected. It invokes success or error callbacks as appropriate.
  • Integrated snapshot monitoring into the Client API by adding watch_snapshot and unwatch_snapshot methods, updating resource cleanup logic, and wiring up the watcher instance. [1] [2] [3] [4]

Documentation and playground updates:

  • Updated the README.md to document the new snapshot monitoring feature and provide usage examples.
  • Refactored playground use case functions and added a new uc_watch_snapshot function to demonstrate snapshot monitoring in tests/playground/index.py. [1] [2] [3] [4] [5] [6]

Testing:

  • Added a new test suite tests/test_client_watch_snapshot.py to verify snapshot monitoring behavior, error handling for missing or malformed snapshot files, and correct callback invocation.
  • Added a malformed snapshot fixture for testing error handling.

@petruki petruki self-assigned this Mar 8, 2026
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 9, 2026

@petruki petruki merged commit c123cd3 into master Mar 9, 2026
15 checks passed
@petruki petruki deleted the staging branch March 9, 2026 00:50
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