-
Notifications
You must be signed in to change notification settings - Fork 252
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
feat(sdk): EventCache
fully uses RoomEvents
/LinkedChunk
#3230
feat(sdk): EventCache
fully uses RoomEvents
/LinkedChunk
#3230
Conversation
6990ec4
to
cd3671f
Compare
9720873
to
6222bbd
Compare
7acc135
to
1f0e3b7
Compare
Marking the PR as Ready for review just to get the CI feedback, but it's not ready for a review :-). Everything seems in-place though, just checking. The history needs to be rewritten. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3230 +/- ##
==========================================
+ Coverage 83.56% 83.60% +0.04%
==========================================
Files 238 238
Lines 24598 24585 -13
==========================================
- Hits 20556 20555 -1
+ Misses 4042 4030 -12 ☔ View full report in Codecov by Sentry. |
30e91e6
to
be9079a
Compare
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.
It's sweet to finally connect the linked chunks implementation to the event cache, nicely done!
A few comments below, and I'd like to take another look after those have been addressed. Thanks!
bf88bea
to
70fb96f
Compare
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.
yay, great job, thank you!
…` and `events`. This patch implements the following wrapper methods (over `LinkedChunk`): `push_gap`, `replace_gap_at` and `events`. This patch also implements the `reset` method that clears/drops all chunks in the `LinkedChunk`.
70fb96f
to
755034e
Compare
The test `test_reset_while_backpaginating` was expecting a race-condition, which no longer exists. It first initially tried to assert a workaround about this race-condition. It doesn't hold anymore. Rewrite the test to assert the (correct) new behaviour.
This patch ensures that operations on `RoomEvents` happen in one block, by sharing the same lock. 2 new methods are created: `replace_all_events_by` and `append_new_events`.
… unknown token. Prior to this patch, in `RoomEventCacheInner::backpaginate`, when the `token` validity was checked, and it was invalid: * before calling `/messages`, `Err(EventCacheError::UnknownBackpaginationToken)` was returned, * after calling `/messages`, `Ok(BackPaginationOutput::UnknownBackpaginationToken)` was returned. This patch tries to uniformize this by only returning `Ok(BackPaginationOutput::UnknownBackpaginationToken)`. That's a tradeoff. It will probably be refactor later. The idea is also to call `/messages` **before** taking the write-lock of `RoomEvents`, otherwise it can keep the lock for up to 30secs in this case. Also, checking the validity of the `token` **before** and **after** `/messages` is not necessary: it can be done only after.
755034e
to
11c3799
Compare
I've rewritten the entire history of this patch. I think we are good! |
EventCache
uses a customEventCacheStore
trait to store all events for all rooms.The idea of this PR is to use the newly introduced
LinkedChunk
in #3166. Instead of having one store for all events for all rooms, now there is oneLinkedChunk
/store per room.Of course, @bnjbvr and I are discussing a lot, which explains why the actual
EventCacheStore
was already adopting some patterns fromLinkedChunk
. The migration was easier.Several PR were necessary to make this work possible:
LinkedChunk
can hold a value forGap
s #3227LinkedChunk
in fix(sdk): Various tiny improvements forLinkedChunk
#3236LinkedChunk
in feat(sdk): Optimise howLinkedChunk::insert_gap_at
works when inserting at first position #3251Briefly, this PR removes the
EventCacheStore
and theMemoryStore
, and replace them byLinkedChunk
.