Skip to content

feat: added local snapshot resolver#6

Merged
petruki merged 2 commits into
masterfrom
staging
May 13, 2026
Merged

feat: added local snapshot resolver#6
petruki merged 2 commits into
masterfrom
staging

Conversation

@petruki
Copy link
Copy Markdown
Member

@petruki petruki commented May 13, 2026

This pull request introduces local snapshot support for evaluating feature switches, enabling offline and deterministic switcher evaluations based on local JSON files. It adds snapshot loading, local criteria evaluation logic, new error types, and comprehensive tests to ensure correctness for various scenarios.

Snapshot support and local evaluation:

  • Added a Snapshot struct and related types in snapshot.go to represent local feature state, with logic for loading, creating, and reading snapshot files.
  • Implemented snapshot loading and version tracking in the Client struct and provided new methods: LoadSnapshot, SnapshotVersion, and internal state management for snapshots in client.go. [1] [2]
  • Introduced local criteria evaluation logic in resolver.go to determine switcher state based on the loaded snapshot, supporting value and network strategies, group and config activation, and relay restrictions.
  • Updated the Switcher logic in switcher.go to use local snapshot evaluation when in local mode, added support for network-based criteria, and improved criteria entry handling. [1] [2] [3] [4]

Error handling:

  • Added a new LocalCriteriaError type in errors.go to distinguish local evaluation errors from remote errors, with corresponding error construction helpers.

Testing:

  • Added a comprehensive test suite in local_test.go covering snapshot loading, error cases, and various switcher evaluation scenarios using local snapshots.

@petruki petruki self-assigned this May 13, 2026
@petruki petruki added enhancement New feature or request ai-assisted Indicates that AI tools were used to assist this with this change labels May 13, 2026
@sonarqubecloud
Copy link
Copy Markdown

@petruki petruki merged commit c034dd8 into master May 13, 2026
7 checks passed
@petruki petruki deleted the staging branch May 13, 2026 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Indicates that AI tools were used to assist this with this change enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant