-
Notifications
You must be signed in to change notification settings - Fork 20
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
Replace wait_for_async_ret
with handle_async_ret
for handling async Ra events
#229
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #229 +/- ##
==========================================
+ Coverage 88.82% 88.84% +0.01%
==========================================
Files 20 20
Lines 2891 2887 -4
==========================================
- Hits 2568 2565 -3
+ Misses 323 322 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
the-mikedavis
force-pushed
the
md-handle-async-ret
branch
from
October 16, 2023 12:50
a8d34e6
to
4f34e38
Compare
dumbbell
requested changes
Oct 31, 2023
the-mikedavis
force-pushed
the
md-handle-async-ret
branch
from
October 31, 2023 13:58
4f34e38
to
401f44b
Compare
the-mikedavis
changed the title
Add
Replace Oct 31, 2023
khepri:handle_async_ret/2
for handling async Ra eventswait_for_async_ret
with handle_async_ret
for handling async Ra events
This is similar to `wait_for_async_ret/1,2` except that the caller is expected to `receive` the Ra event. This is necessary because the Ra event sent when a batch of commands is applied includes a list of correlation and result pairs, making it impossible to use a selective receive to look for a single correlation ID. We could alternatively map the `ra_event` message into some other value like `{ok, Correlations} | {error, CorrelationId}` but this isn't much easier to work with than the `ra_event`s themselves and would be brittle for changes to `ra_event`. Instead we leave it to the caller to receive and handle the events. This function is then responsible only for calling internal functions to update the cached leader for the given store ID.
See the parent commit: `wait_for_async_ret/1,2` used a selective receive to find whether a given correlation ID was applied. The `ra_event` emitted when a batch is applied gives all correlation and result pairs applied in the batch though, making it impossible to reliably find a single correlation ID. We should instead have the caller perform the `receive` to find the applied/rejected event and handle all of the correlation IDs found within. So this change removes `wait_for_async_ret/1,2` in favor of the `handle_async_ret/2` function added in the parent commit.
the-mikedavis
force-pushed
the
md-handle-async-ret
branch
from
October 31, 2023 14:40
401f44b
to
a25e695
Compare
dumbbell
approved these changes
Oct 31, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is similar to
wait_for_async_ret/1,2
except that the caller is expected toreceive
the Ra event. This is necessary because the Ra event sent when a batch of commands is applied includes a list of correlation and result pairs, making it impossible to use a selective receive to look for a single correlation ID.We could alternatively map the
ra_event
message into some other value like{ok, Correlations} | {error, CorrelationId}
but this isn't much easier to work with than thera_event
s themselves and would be brittle for changes tora_event
. Instead we leave it to the caller to receive and handle the events. This function is then responsible only for calling internal functions to update the cached leader for the given store ID.I've also added deprecations for
wait_for_async_ret/1,2
since it can't be used to reliably find if a given correlation ID was applied. Instead we should prefer to have the callerreceive
the Ra event and handle the correlation IDs within.