Skip to content

Conversation

mgoldenberg
Copy link
Contributor

@mgoldenberg mgoldenberg commented Aug 7, 2025

Background

This pull request is part of a series of pull requests to add a full IndexedDB implementation of the EventCacheStore (see #4617, #4996, #5090, #5138, #5226, #5274, #5343, #5384, #5406, #5414, #5497). This particular pull request adds an IndexedDB-backed implementation of EventCacheStore::try_take_leased_lock.

Changes

The following types have been added for representing and indexing leased locks.

  • Lease - the primary type for representing a leased lock.
  • IndexedLease - an indexed version of Lease.
  • IndexedLeaseIdKey - the primary key of an IndexedLease.

To store the types above, an object store (v1::keys::LEASES) gets created when upgrading the database to version 1 with primary key id.

Additionally, the following transaction functions are added for conveniently working with leases.

  • IndexeddbEventCacheStoreTransaction::get_lease_by_id
  • IndexeddbEventCacheStoreTransaction::put_lease

Tests

matrix_sdk_base::event_cache_store_integration_tests_time previously used tokio::time::sleep which is not supported on wasm targets.

The time module will only work on WASM platforms that have support for timers (e.g. wasm32-wasi). The timing functions will panic if used on a WASM platform that does not support timers.

(Link to text here).

I have modified this macro so that when running on wasm targets with an unknown operating system, we use a compatible crate, i.e., gloo_timers. This way, these tests can be run against the matrix-sdk-indexeddb crate.

Future Work

  • Proper handling of LinkedChunkId (see here).
  • Add implementation of EventCacheStoreMedia

  • Public API changes documented in changelogs (optional)

Signed-off-by: Michael Goldenberg [email protected]

Copy link

codecov bot commented Aug 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.57%. Comparing base (01059ef) to head (c4431cc).
⚠️ Report is 10 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5506   +/-   ##
=======================================
  Coverage   88.57%   88.57%           
=======================================
  Files         340      340           
  Lines       93665    93665           
  Branches    93665    93665           
=======================================
+ Hits        82960    82964    +4     
+ Misses       6575     6569    -6     
- Partials     4130     4132    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mgoldenberg mgoldenberg marked this pull request as ready for review August 7, 2025 19:55
@mgoldenberg mgoldenberg requested a review from a team as a code owner August 7, 2025 19:55
@mgoldenberg mgoldenberg requested review from Hywan and removed request for a team August 7, 2025 19:55
Copy link

codspeed-hq bot commented Aug 8, 2025

CodSpeed Performance Report

Merging #5506 will not alter performance

Comparing mgoldenberg:indexeddb-event-cache-store-lease (c4431cc) with main (cf9d058)

Summary

✅ 31 untouched benchmarks

Copy link
Member

@Hywan Hywan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks! A few tiny feedback. Apart from that, great job.

@mgoldenberg mgoldenberg requested a review from Hywan August 12, 2025 02:30
@Hywan
Copy link
Member

Hywan commented Aug 13, 2025

Good! Can you rebase your history please? Then we can merge the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants