Skip to content
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

Ensure PresenceChangedEvent is triggered after presences emission #151

Closed
wants to merge 5 commits into from

Conversation

7hong13
Copy link
Contributor

@7hong13 7hong13 commented Jan 19, 2024

What this PR does / why we need it?

It ensures that the PresenceChanged event is posted after the presences flow emission.

Any background context you want to provide?

What are the relevant tickets?

Fixes #

Checklist

  • Added relevant tests or not required
  • Didn't break anything

@7hong13 7hong13 requested review from hackerwins and skhugh January 19, 2024 05:37
@7hong13 7hong13 self-assigned this Jan 19, 2024
Copy link

codecov bot commented Jan 19, 2024

Codecov Report

Attention: 46 lines in your changes are missing coverage. Please review.

Comparison is base (5989f50) 78.46% compared to head (3f8c591) 79.58%.
Report is 3 commits behind head on main.

Files Patch % Lines
...c/main/kotlin/dev/yorkie/document/crdt/CrdtTree.kt 83.33% 4 Missing and 28 partials ⚠️
...ie/src/main/kotlin/dev/yorkie/document/Document.kt 50.00% 5 Missing and 3 partials ⚠️
yorkie/src/main/kotlin/dev/yorkie/core/Client.kt 40.00% 3 Missing ⚠️
...c/main/kotlin/dev/yorkie/document/json/JsonTree.kt 80.00% 2 Missing ⚠️
...orkie/src/main/kotlin/dev/yorkie/util/IndexTree.kt 94.44% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #151      +/-   ##
==========================================
+ Coverage   78.46%   79.58%   +1.11%     
==========================================
  Files          63       63              
  Lines        3743     3845     +102     
  Branches      582      601      +19     
==========================================
+ Hits         2937     3060     +123     
+ Misses        500      463      -37     
- Partials      306      322      +16     

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

Copy link
Contributor

@skhugh skhugh left a comment

Choose a reason for hiding this comment

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

I'm not sure if this will be consistent when presences events occur very rapidly.
Maybe we should add test codes to be sure.


else -> {}
}
withTimeoutOrNull(3_000) {
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need the timeout?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is logically unnecessary, but I added it just in case of an unexpected issue which can lead to an indefinite delay in the first() function.
I'll remove it if it looks redundant.

else -> {}
}
withTimeoutOrNull(3_000) {
presences.first(predicate)
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible for presence events to be changed as below very fast that publishPresenceEvent for publishPresenceEvent is called after it is already unwatched?

Watched -> PresenceChanged -> Unwatched

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not 100% sure that situation will never happen.
I'll fix it to ensure that the PresenceChanged event is ignored when it is already unwatched.

@7hong13
Copy link
Contributor Author

7hong13 commented Jan 22, 2024

I'm not sure if this will be consistent when presences events occur very rapidly.
Maybe we should add test codes to be sure.

I haven't checked for rapidly changing presence events, so I'll look into it further and add test codes for it.

@7hong13 7hong13 marked this pull request as draft January 25, 2024 09:11
@7hong13 7hong13 closed this Mar 18, 2024
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