Skip to content

Add gen_server async request APIs (send_request, wait/receive/check_response/…)#30

Merged
kjnilsson merged 2 commits intomasterfrom
request-api
Apr 1, 2026
Merged

Add gen_server async request APIs (send_request, wait/receive/check_response/…)#30
kjnilsson merged 2 commits intomasterfrom
request-api

Conversation

@kjnilsson
Copy link
Copy Markdown
Contributor

@kjnilsson kjnilsson commented Mar 31, 2026

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.

…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.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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/*, and reqids_* wrapper APIs delegating to gen.
  • Switch reply handling in handle_actions/2 from raw Pid ! {Tag, Msg} to gen:reply/2 for 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.

Comment thread README.md Outdated
@rabbitmq rabbitmq deleted a comment from Copilot AI Mar 31, 2026
@michaelklishin michaelklishin changed the title Add gen_server async request APIs (send_request, wait/receive/check_r… Add gen_server async request APIs (send_request, wait/receive/check_response/…) Mar 31, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@kjnilsson kjnilsson marked this pull request as ready for review April 1, 2026 07:56
@kjnilsson kjnilsson merged commit f2347d8 into master Apr 1, 2026
3 checks passed
@michaelklishin michaelklishin added this to the 0.10.0 milestone Apr 1, 2026
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.

3 participants