-
Notifications
You must be signed in to change notification settings - Fork 375
IndexedDB: Add transaction functionality for EventCacheStore backend
#5274
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
IndexedDB: Add transaction functionality for EventCacheStore backend
#5274
Conversation
…ializer error This prevents us from having to add type constraints on the dynamic type and instead only having to specify the type constraint at the call site. Signed-off-by: Michael Goldenberg <[email protected]>
… components Signed-off-by: Michael Goldenberg <[email protected]>
…lower, encode_upper} Signed-off-by: Michael Goldenberg <[email protected]>
Signed-off-by: Michael Goldenberg <[email protected]>
Signed-off-by: Michael Goldenberg <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## main #5274 +/- ##
==========================================
- Coverage 90.18% 90.18% -0.01%
==========================================
Files 334 334
Lines 104822 104822
Branches 104822 104822
==========================================
- Hits 94538 94536 -2
- Misses 6231 6233 +2
Partials 4053 4053 ☔ View full report in Codecov by Sentry. |
Hywan
left a comment
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.
Excellent! Thank you for the clean patches, it's really helpful.
I made a few feedback but nothing important.
I was wondering: can we add tests for this? Or is it for a next PR?
crates/matrix-sdk-indexeddb/src/event_cache_store/serializer/types.rs
Outdated
Show resolved
Hide resolved
crates/matrix-sdk-indexeddb/src/event_cache_store/serializer/types.rs
Outdated
Show resolved
Hide resolved
crates/matrix-sdk-indexeddb/src/event_cache_store/serializer/traits.rs
Outdated
Show resolved
Hide resolved
crates/matrix-sdk-indexeddb/src/event_cache_store/transaction.rs
Outdated
Show resolved
Hide resolved
crates/matrix-sdk-indexeddb/src/event_cache_store/transaction.rs
Outdated
Show resolved
Hide resolved
|
A quick comment about the The While these concepts are similar and often produce the same results, there are cases where these two concepts produce very different results. Namely, when any of the components are encrypted in the process of constructing the final key, then the component bounds and the key bounds produce very different results. So, for instance, consider the Note that this is mentioned in the final version of the traits, see here. |
So, in my branch with all the changes, I only have tests of the Do you think we should have more than that? If so, I'd be happy to add more now or in a future pull request. For context, I'll also be adding typed versions of all the functions in Let me know what you're thinking! |
|
About #5274 (comment) — It's great the last part is mentioned in the doc but the first 2/3 of the comment is also truly valuable! Can you add that on the documentation of About #5274 (comment) — It depends of how much efforts it represents for you. We already have unit tests and integration tests for the |
|
You can rebase your fixup commits, then we can merge the PR. |
Signed-off-by: Michael Goldenberg <[email protected]>
…key range enum Signed-off-by: Michael Goldenberg <[email protected]>
…ponent range Signed-off-by: Michael Goldenberg <[email protected]>
…exed trait Signed-off-by: Michael Goldenberg <[email protected]>
… trait Signed-off-by: Michael Goldenberg <[email protected]>
…cific to event cache store Signed-off-by: Michael Goldenberg <[email protected]>
…ta out of IndexedDB Signed-off-by: Michael Goldenberg <[email protected]>
…a to IndexedDB Signed-off-by: Michael Goldenberg <[email protected]>
…ata from IndexedDB Signed-off-by: Michael Goldenberg <[email protected]>
Signed-off-by: Michael Goldenberg <[email protected]>
…l data from an object store in IndexedDB Signed-off-by: Michael Goldenberg <[email protected]>
…edKeyComponentBounds`.
bb8c01b to
582cfa1
Compare
Background
This pull request is part of a series of pull requests to add an IndexedDB implementation of the
EventCacheStore(see #4617, #4996, #5090, #5138, #5226). This particular pull request primarily focuses on providing functionality for easily issuing IndexedDB transaction.Changes
The primary change is the addition of
IndexeddbEventCacheStoreTransaction, which wrapsIdbTransactionandIndexedbEventCacheStoreSerializer. It provides a convenient interface for composing atomic IndexedDB operations. For the sake of brevity, I have only added the generic versions of the functions for these operations, but as we add implementations of the functions inEventCacheStore, I will bring in their typed versions where relevant.Additionally, in order to support some of the generic functions in
IndexeddbEventCacheStoreTransaction, I have introduced another trait and some minor changes to the existing ones.IndexedKeyComponentBounds(trait)IndexedKeyBounds, but generates the lower and upper bounds of the key components, rather than the key itself. This is useful when constructing key ranges, except in the case where a particular key component is encrypted, in which case one must construct the ranges from the keys themselves.IndexedKeyRange(type)Indexed(trait)OBJECT_STORE: &'static strIndexedKey(trait)index() -> Option<&'static str>IndexedKeyBounds(trait)encode_lower_key->lower_keyto more closely mirrorIndexedKeyComponentBoundsencode_upper_key->upper_keyto more closely mirrorIndexedKeyComponentBoundsIndexeddbEventCacheStoreSerializerErrorIndexingvariant uses generic type, rather than dynamic type so thatSendandSyncdon't have to be used as constraints where they aren't necessary.Future Work
EventCacheStorewhich uses the transaction type added in this pull request.Signed-off-by: Michael Goldenberg [email protected]