-
Notifications
You must be signed in to change notification settings - Fork 358
IndexedDB: use implementations of EventCacheStore and MediaStore in client
#5946
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
base: main
Are you sure you want to change the base?
IndexedDB: use implementations of EventCacheStore and MediaStore in client
#5946
Conversation
… name Signed-off-by: Michael Goldenberg <[email protected]>
Signed-off-by: Michael Goldenberg <[email protected]>
Signed-off-by: Michael Goldenberg <[email protected]>
Signed-off-by: Michael Goldenberg <[email protected]>
… serializers Signed-off-by: Michael Goldenberg <[email protected]>
…ation Signed-off-by: Michael Goldenberg <[email protected]>
…n isolation Signed-off-by: Michael Goldenberg <[email protected]>
Signed-off-by: Michael Goldenberg <[email protected]>
Signed-off-by: Michael Goldenberg <[email protected]>
Signed-off-by: Michael Goldenberg <[email protected]>
Signed-off-by: Michael Goldenberg <[email protected]>
Signed-off-by: Michael Goldenberg <[email protected]>
Signed-off-by: Michael Goldenberg <[email protected]>
CodSpeed Performance ReportMerging #5946 will not alter performanceComparing Summary
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5946 +/- ##
==========================================
- Coverage 88.50% 88.50% -0.01%
==========================================
Files 362 362
Lines 103351 103351
Branches 103351 103351
==========================================
- Hits 91474 91470 -4
- Misses 7531 7534 +3
- Partials 4346 4347 +1 ☔ 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.
Thanks for the patches!
I wonder why we would need a struct holding all the stores. We don't have that for SQLite nor in-memory stores. Why is it important here?
| safe-encode-traits = [] | ||
| safe-encode-serializer = ["dep:matrix-sdk-crypto", "safe-encode-traits"] |
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.
What safe means here?
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.
safe is part of the name of an encoder and serializer - i.e., trait SafeEncode.
I agree that this isn't a good name for a feature, but it helps a lot to have more granular feature flags when adding [#cfg(feature = ...)] statements in the code. I thought about prefixing it with _ or internal- to show that it really isn't for an end user, but for internal organization.
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.
Open to other directions with this!
| - `StoreConfig::new()` now takes a | ||
| `cross_process_store_locks_holder_name` argument. | ||
| - `StoreConfig` no longer implements `Default`. | ||
| - `BaseClient::new()` has been removed. | ||
| - `BaseClient::clone_with_in_memory_state_store()` now takes a | ||
| `cross_process_store_locks_holder_name` argument. | ||
| - `BaseClient` no longer implements `Default`. | ||
| - `EventCacheStoreLock::new()` no longer takes a `key` argument. | ||
| - `BuilderStoreConfig` no longer has | ||
| `cross_process_store_locks_holder_name` field for `Sqlite` and | ||
| `IndexedDb`. |
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.
Nop, those are a sublist of the previous item.
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.
Oh... these must be formatting changes... would you like me to try to revert them? I didn't realize those were in there!
| ```rust | ||
| // Get an observer. | ||
| let observer = | ||
| client.observe_events::<SyncRoomMessageEvent, (Room, Vec<Action>)>(); | ||
|
|
||
| // Subscribe to the observer. | ||
| let mut subscriber = observer.subscribe(); | ||
| // Subscribe to the observer. | ||
| let mut subscriber = observer.subscribe(); | ||
|
|
||
| // Use the subscriber as a `Stream`. | ||
| let (message_event, (room, push_actions)) = subscriber.next().await.unwrap(); | ||
| ``` | ||
| // Use the subscriber as a `Stream`. | ||
| let (message_event, (room, push_actions)) = subscriber.next().await.unwrap(); | ||
| ``` | ||
|
|
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.
Nop.
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.
Same as above!
I was mostly just trying to stick to the pattern that was already established in I am happy to re-think this and, instead, expose functions that enable users of the crate to construct each store individually. However, there's one consideration to note about going that route. The original author initialized a single pub async fn open_stores_with_name(
name: &str,
passphrase: Option<&str>,
) -> Result<(IndexeddbStateStore, IndexeddbCryptoStore), OpenStoreError> {
// -- snip --
let crypto_store =
IndexeddbCryptoStore::open_with_store_cipher(name, state_store.store_cipher.clone())
.await?;
// -- snip --
}I'm not sure why this was done, but it requires access to In order to allow users of the crate to construct each store individually, we would have to do one of two things.
Let me know what you think, happy to go in any direction! And also happy to explain more if this isn't making sense. |
Background
This is the final pull request in the series of pull requests to add a full IndexedDB implementation of the
EventCacheStoreandMediaStore(see #4617, #4996, #5090, #5138, #5226, #5274, #5343, #5384, #5406, #5414, #5497, #5506, #5540, #5574, #5603, #5676, #5682, #5749, #5795, #5933). This particular pull request adds the IndexedDB implementations ofEventCacheStoreandMediaStoreinto thematrix_sdk::Clientwhen it is configured to use IndexedDB as its data store.Changes
Expose
EventCacheStoreandMediaStorefunctions outsidematrix-sdk-indexeddbThis involved re-exporting some of the types internal to the crate - e.g.,
IndexeddbEventCacheStoreandIndexeddbMediaStore.Additionally, a composite type was added to hold all stores in a single structure - i.e.,
IndexeddbStores. This structure is also equipped with a set of functions for opening all the stores with a single function call.Refactor feature flags
There were some issues with enabling individual feature flags - e.g., enabling
event-cache-storeormedia-storewithoute2e-encryptionfailed to compile. These issues surfaced once trying to use them viamatrix-sdk.The flags have been refactored so that each of the different stores may be used independent of and in combination with the others.
Use implementations of
EventCacheStoreandMediaStoreinmatrix-sdk::Clientmatrix_sdk::client::builder::build_indexeddb_store_confighas been updated so that it initializes theStoreConfigwith IndexedDB implementations of all of the stores. And, of course, it includes the crypto store whene2e-encryptionis enabled.Signed-off-by: Michael Goldenberg [email protected]