adoy / PHP-FastCGI-Client

Lightweight, single file, FastCGI client for PHP
MIT License
302 stars 61 forks source link

Support multiplexing multiple async requests over persistent socket #4

Closed banks closed 10 years ago

banks commented 10 years ago

@adoy, thanks for this lib allowed me to test proof of concept quickly.

This is a quick hour's pass through the lib but I wanted to share the changes back with you. They are unfortunately only tested with trivial ad-hoc script but I will probably be using this library extensively in a new project so will contribute back any further changes.

This change allows stuff like:

for ($i = 0; $i < 3; $i++) {
    $req_ids[] = $client->async_request($params, false);
} 

// Do other stuff while they all process in parallel (assuming your FastCGI application is multi-threaded)

foreach ($req_ids as $id) {
    $response = $client->wait_for_response($id);
}

I will use this as basis of an Async RPC framework using FastCGI applications as backend services to a PHP web app.

Any thoughts/clean up requests welcome.