xp-forge / xp-forge/rest-client
Asynchronous invocation
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 0
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
If used inside a single-threaded xp-forge/web web application, waiting will block the entire server. We should also have an asynchronous method to execute requests and wait for them.
Blocks server until API call returns
Current functionality
function($req, $res) use($endpoint) {
$user= $endpoint->resource('/users/me')->get()->value();
$res->answer(200);
$res->write('Hello '.$user['displayName'], 'text/plain');
}
Asynchronous handler function
Idea: Defer reading from request until any of RestResponse's methods are called, add await():
function($req, $res) use($endpoint) {
$user= (yield $endpoint->resource('/users/me')->get()->await())->value();
$res->answer(200);
$res->write('Hello '.$user['displayName'], 'text/plain');
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the current request flow described in the issue, especially RestResponse methods and the endpoint resource('/users/me')->get()->value() call. Compare it with the proposed generator-based await() handler and determine how deferred reading should interact with the response methods. Done means asynchronous invocation can avoid blocking a single-threaded xp-forge/web server while preserving the existing response behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100