Add gen_server async request APIs (send_request, wait/receive/check_response/…)#30
Merged
Add gen_server async request APIs (send_request, wait/receive/check_response/…)#30
Conversation
…esponse, reqids_*)
Expose the gen_server "request" family of functions so callers can make
asynchronous calls to a gen_batch_server and collect replies later. All
twelve new functions delegate to the gen module, matching what gen_server
itself does internally.
Also fix the reply path in handle_actions/2 to use gen:reply/2 instead
of raw Pid ! {Tag, Msg}. This is required for alias-based From tags
produced by send_request to route replies through the process alias,
ensuring late replies after timeout are silently dropped. The change is
backward-compatible with legacy gen:call-style From values.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR exposes OTP’s gen “async request” API surface on gen_batch_server, allowing callers to issue asynchronous calls and collect replies later (including request-id collections). It also updates the server reply path to use gen:reply/2 so alias-based From tags produced by send_request/* are handled correctly.
Changes:
- Add
send_request/*,wait_response/*,receive_response/*,check_response/*, andreqids_*wrapper APIs delegating togen. - Switch reply handling in
handle_actions/2from rawPid ! {Tag, Msg}togen:reply/2for alias-aware reply routing. - Add Common Test coverage and README documentation for the new async request APIs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/gen_batch_server.erl |
Exports and implements async request/response APIs; uses gen:reply/2 for replies. |
test/gen_batch_server_SUITE.erl |
Adds CT testcases covering the new async request APIs and request-id collections. |
README.md |
Documents the newly exposed async request/response and request-id collection APIs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or 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
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.
Expose the gen_server "request" family of functions so callers can make asynchronous calls to a gen_batch_server and collect replies later. All twelve new functions delegate to the gen module, matching what gen_server itself does internally.
Also fix the reply path in handle_actions/2 to use gen:reply/2 instead of raw Pid ! {Tag, Msg}. This is required for alias-based From tags produced by send_request to route replies through the process alias, ensuring late replies after timeout are silently dropped. The change is backward-compatible with legacy gen:call-style From values.