-
Notifications
You must be signed in to change notification settings - Fork 18
Backend API changes - backends independent from filesystems #126
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
Backend API changes - backends independent from filesystems #126
Conversation
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.
Pull Request Overview
This PR refactors the KVS (Key-Value Storage) library to make backends independent from filesystems. The primary purpose is to redesign the architecture where KVS instances use a pluggable backend system rather than being tightly coupled to file operations.
Key changes include:
- Redesigned KVS architecture with a pluggable backend system via trait objects
- Moved file operations from KVS core to JsonBackend implementation
- Updated builder pattern to use backend-based configuration instead of directory strings
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/rust/rust_kvs/src/lib.rs | Updated module visibility and prelude to expose backend types |
| src/rust/rust_kvs/src/kvs_backend.rs | Defined new KvsBackend trait with backend operations |
| src/rust/rust_kvs/src/kvs_builder.rs | Refactored builder to use backends and instance pooling |
| src/rust/rust_kvs/src/kvs.rs | Simplified KVS struct to delegate operations to backends |
| src/rust/rust_kvs/src/json_backend.rs | Moved file operations from KVS core to JsonBackend |
| src/rust/rust_kvs/src/kvs_api.rs | Updated API to remove file path methods and static functions |
| tests/rust_test_scenarios/src/main.rs | Commented out test code (temporary during refactoring) |
| src/rust/rust_kvs_tool/src/kvs_tool.rs | Updated tool to work with new backend system |
| examples/* | Updated examples to use new backend-based API |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
License Check Results🚀 The license check job ran with the Bazel command: bazel run //:license-checkStatus: Click to expand output |
|
The created documentation from the pull request is available at: docu-html |
36fe007 to
876ca7c
Compare
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.
Pull Request Overview
Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (2)
src/rust/rust_kvs/src/kvs_builder.rs:1
- Parameter
_kvshas been renamed tokvsbut the leading underscore suggests it was intended to indicate an unused parameter. Since the parameter is now used on line 303, the underscore should be removed from the parameter name.
// Copyright (c) 2025 Contributors to the Eclipse Foundation
src/rust/rust_kvs/src/kvs_builder.rs:1
- The constant
KVS_MAX_SNAPSHOTSis no longer defined in this module after the refactor. This should usekvs.snapshot_max_count()instead to get the maximum snapshot count from the KVS instance.
// Copyright (c) 2025 Contributors to the Eclipse Foundation
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
a195eb0 to
70b1b04
Compare
1a045f1 to
45f46ff
Compare
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.
Pull Request Overview
Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| fn flush(&self) -> Result<(), ErrorCode> { | ||
| if self.snapshot_max_count() == 0 { | ||
| eprintln!("warn: snapshot_max_count == 0, flush ignored"); | ||
| return Ok(()); |
Copilot
AI
Sep 19, 2025
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.
[nitpick] Silently turning flush into a no-op when snapshot_max_count == 0 may surprise API users: data mutations are never persisted but no error is surfaced. Consider (a) documenting this explicitly, (b) returning a distinct ErrorCode, or (c) still persisting a non-rotated 'current' state even when rotation is disabled.
| fn flush(&self) -> Result<(), ErrorCode> { | |
| if self.snapshot_max_count() == 0 { | |
| eprintln!("warn: snapshot_max_count == 0, flush ignored"); | |
| return Ok(()); | |
| /// * `ErrorCode::SnapshotsDisabled`: Snapshots are disabled (snapshot_max_count == 0) | |
| fn flush(&self) -> Result<(), ErrorCode> { | |
| if self.snapshot_max_count() == 0 { | |
| eprintln!("warn: snapshot_max_count == 0, flush ignored"); | |
| return Err(ErrorCode::SnapshotsDisabled); |
| /// KVS backend interface. | ||
| pub trait KvsBackend: DynEq + Sync + Send { | ||
| /// Load KVS content. | ||
| fn load_kvs( | ||
| &self, | ||
| instance_id: InstanceId, | ||
| snapshot_id: SnapshotId, | ||
| ) -> PathBuf; | ||
| ) -> Result<KvsMap, ErrorCode>; | ||
|
|
||
| /// Get hash file name. | ||
| fn hash_file_name(instance_id: InstanceId, snapshot_id: SnapshotId) -> String; | ||
| /// Load default values. | ||
| fn load_defaults(&self, instance_id: InstanceId) -> Result<KvsMap, ErrorCode>; | ||
|
|
||
| /// Get hash file path in working directory. | ||
| fn hash_file_path( | ||
| working_dir: &Path, | ||
| instance_id: InstanceId, | ||
| snapshot_id: SnapshotId, | ||
| ) -> PathBuf; | ||
| /// Flush KvsMap to persistent storage. | ||
| /// Snapshots are rotated and current state is stored as first (0). | ||
| fn flush(&self, instance_id: InstanceId, kvs_map: &KvsMap) -> Result<(), ErrorCode>; | ||
|
|
||
| /// Count available snapshots. | ||
| fn snapshot_count(&self, instance_id: InstanceId) -> usize; | ||
|
|
||
| /// Get defaults file name. | ||
| fn defaults_file_name(instance_id: InstanceId) -> String; | ||
| /// Max number of snapshots. | ||
| fn snapshot_max_count(&self) -> usize; | ||
|
|
||
| /// Get defaults file path in working directory. | ||
| fn defaults_file_path(working_dir: &Path, instance_id: InstanceId) -> PathBuf; | ||
| /// Restore snapshot with given ID. | ||
| fn snapshot_restore( | ||
| &self, | ||
| instance_id: InstanceId, | ||
| snapshot_id: SnapshotId, | ||
| ) -> Result<KvsMap, ErrorCode>; | ||
| } |
Copilot
AI
Sep 19, 2025
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.
Public trait lacks documentation about critical behavioral contracts: (a) whether snapshot_id == 0 is always invalid for restore, (b) expected error codes for missing or partially missing snapshot/hash files, (c) flush semantics when snapshot_max_count is 0, and (d) concurrency expectations (atomicity / ordering). Adding these clarifications will make it easier to implement alternative backends correctly.
45f46ff to
90bd149
Compare
b6d018d to
4030295
Compare
4030295 to
3ffbfaf
Compare
- New `KvsBackend` API - independent from filesystem.
- Make `JsonBackend` explicitly default, allow others.
- Add `JsonBackendBuilder`.
- This is required to allow for defaults override without setters.
- E.g., `snapshot_max_count` can be set, but shouldn't change after
init.
- Update tests.
3ffbfaf to
3bdac66
Compare
|
Merged changes with other PR, moved here #150 |
No description provided.