feat(durable object): expose SyncKvStorage#978
Open
chise0713 wants to merge 9 commits intocloudflare:mainfrom
Open
feat(durable object): expose SyncKvStorage#978chise0713 wants to merge 9 commits intocloudflare:mainfrom
SyncKvStorage#978chise0713 wants to merge 9 commits intocloudflare:mainfrom
Conversation
- add wasm bindings for `SyncKvStorage` - expose `kv()` on `DurableObjectStorage` - add missing `startAfter` to `ListOptions` (present in workerd)
- more error handling at the `Iterator` impl
…ions Address review feedback on the SyncKvStorage bindings and bring them in line with the patterns used elsewhere in worker-sys. worker-sys: - SyncKvStorage methods now have both non-throwing and `try_*` (`catch`) variants, matching the convention used for other Durable Object bindings - `extends = Object` with `#[derive(Debug, Clone, PartialEq, Eq)]` - `put(value: &JsValue)` takes by reference; `list()` returns `JsValue` since `Iterable<[string, T]>` has no wasm-bindgen mapping - New `SyncKvListOptions` extern type with getters/setters for every field, exposing the JS object directly rather than serialising a Rust struct worker: - High-level `SyncKvStorage` calls the `try_*` sys variants so JS exceptions surface as `Error` instead of aborting - `delete` now returns `Result<bool>` to match the fallible JS call - `SyncKvListOptions` is re-exported from `worker-sys` directly; construction is via `SyncKvListOptionsBuilder::new()` which mutates the underlying JS object in place \u2014 no Rust-owned intermediate representation - Reverted `startAfter` from `durable::ListOptions`; that field belongs to the async storage API and should land separately - Tightened `SyncKvIterator::next` to use `dyn_into::<Array>` instead of dual checks; alphabetised `mod` ordering in lib.rs example: - Renamed wrangler worker name from `worker-rs-test` to `sync-kv-example` to avoid colliding with the test crate's deployed worker name - Aligned `compatibility_date` with the test crate's (`2025-09-23`) - Renamed `Test` durable object to `SyncKvDurableObject` for clarity tests: - Added `/list_options` exercising `start`, `start_after`, `end`, `reverse`, and `limit` against real workerd behaviour - Updated existing assertions for the new `Result<bool>` shape of `delete` - Use `collect::<Result<Vec<_>>>()?` instead of `.unwrap()` so test failures surface useful errors - Moved `KEYS_LEN` const into the arms that use it - Added missing trailing newlines on new files
Merging this PR will not alter performance
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SyncKvStorage, referencekv()onDurableObjectStoragestartAftertoListOptions(present in workerd, both async kv and sync kv)Related: #967