-
Notifications
You must be signed in to change notification settings - Fork 376
IndexedDB: Add initial types and database migrations for EventCacheStore backend
#5138
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 initial types and database migrations for EventCacheStore backend
#5138
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5138 +/- ##
==========================================
+ Coverage 85.15% 85.16% +0.01%
==========================================
Files 329 329
Lines 36923 36923
==========================================
+ Hits 31442 31447 +5
+ Misses 5481 5476 -5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pretty cool! I have a couple of tiny feedback. Other than that, it's good and easy to follow. Thanks! I'm enjoying the code structure.
crates/matrix-sdk-indexeddb/src/event_cache_store/serializer/types.rs
Outdated
Show resolved
Hide resolved
|
By the way, I made one additional change aside from those you requested. Basically, the change is that pub struct GenericEvent<P> {
...,
pub position: Option<P>, // => position: P
}
pub type InBandEvent = GenericEvent<Position>;
pub type OutOfBandEvent = GenericEvent<()>;This is already the case in another branch where I have all my changes, but I must have made a mistake when copying the code over into this branch. |
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.
A couple of feedback regarding the doc, and a more robust Version enum to replace u32. Other than that, we are good!
crates/matrix-sdk-indexeddb/src/event_cache_store/migrations.rs
Outdated
Show resolved
Hide resolved
crates/matrix-sdk-indexeddb/src/event_cache_store/migrations.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/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/types.rs
Outdated
Show resolved
Hide resolved
|
@Hywan, sorry about the last minute changes after re-requesting a review 😬 I am working on the implementation in a separate branch, and realized some of the types should change slightly. At any rate, I figured I might be able to sneak those changes in before you review - hope that's okay! |
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.
All good to me! Congrats and thank you very much. Can you rebase your history please? Or would you prefer we squash everything on our side?
Signed-off-by: Michael Goldenberg <[email protected]>
Signed-off-by: Michael Goldenberg <[email protected]>
Signed-off-by: Michael Goldenberg <[email protected]>
…ndexing in event cache store Signed-off-by: Michael Goldenberg <[email protected]>
…ndexing in event cache store Signed-off-by: Michael Goldenberg <[email protected]>
…in-band/out-of-band events Signed-off-by: Michael Goldenberg <[email protected]>
…tifiers rather than entire chunks Signed-off-by: Michael Goldenberg <[email protected]>
…ent cache store Signed-off-by: Michael Goldenberg <[email protected]>
…ng for compatibility with SafeEncode Signed-off-by: Michael Goldenberg <[email protected]>
…rts numeric keys Signed-off-by: Michael Goldenberg <[email protected]>
…dexedDB supports numeric keys Signed-off-by: Michael Goldenberg <[email protected]>
…next chunk does not exist Signed-off-by: Michael Goldenberg <[email protected]>
51b302e to
922ea91
Compare
|
I rebased - hopefully everything passes! |
Background
This pull request is part of a series of pull requests to add an IndexedDB implementation of the
EventCacheStore(see #4617, #4996, #5090). This particular pull request provides initial types and a database schema.Changes
This change does not expose any code, but simply adds the initial types and migrations that will be used in the implementation of
EventCacheStore. Ideally, the schema would mimic the one used in the SQLite implementation ofEventCacheStore, but given that IndexedDB is not relational, the schema needed some modification.Queries
The following queries are used in the implementation of
EventCacheStoreand so, must be supported in our schema.RoomId→ NextChunkIdentifierRoomId,ChunkIdentifier→ AllEvents in correspondingChunkRoomId→ LastChunkinLinkedChunksRoomId,EventId→EventRoomId,EventId→Position, if any, inLinkedChunksRoomId,EventId,RelationType→ AllEvents related toEventIdbyRelationTypeSchema
CORE- Object storeLINKED_CHUNKS- Object storeid- composed ofRoomIdandChunkIdentifierChunkLINKED_CHUNKS_NEXT- Index onLINKED_CHUNKSnext- composed ofRoomIdandChunkIdentifierLINKED_CHUNKSEVENTS- Object storeid- composed ofRoomIdandEventIdEventEVENTS_POSITION- Index onEVENTSposition- composed ofRoomIdandChunkIdentifierEVENTSEVENTS_RELATION- Index onEVENTSrelation- composed ofRoomId,EventId,RelationTypeEVENTSTypes
There are two sets of types which will be used for performing various operations.
event_cache_store::types- decrypted, used for high-level operations on the data itselfevent_cache_store::serializer::types- may be encrypted, used to store encoded data but exposes certain values for effective queryingThese types will have implicit conversions from one to the other during (de)serialization, however, that is not included in this pull request.
Future Work
event_cache_store::typesEventCacheStorewhich uses these typesSigned-off-by: Michael Goldenberg [email protected]