-
Notifications
You must be signed in to change notification settings - Fork 83
How to implement in a ReactPHP app? #214
Comments
Would you mind to share your example code to have a clearer picture on what
you try to instrument?
Den søn. 21. okt. 2018, 21:42 skrev Albert Casademont <
[email protected]>:
… Hi! Seems like the library is heavily geared towards the classic PHP
single-request mode. How should I instrument my code for a ReactPHP use
case? A single PHP process handles multiple requests.
Thanks!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#214>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AC7sAr2FzyG0zzEi3aetM0eVVrAmmWsZks5unM4ygaJpZM4XyobZ>
.
|
Sure, this is taken from ReactPHP's website, for example $loop = React\EventLoop\Factory::create();
$server = new React\Http\Server(function (Psr\Http\Message\ServerRequestInterface $request) {
//Lots of calls and work here
return new React\Http\Response(
200,
array('Content-Type' => 'text/plain'),
"Hello World!\n"
);
});
$socket = new React\Socket\Server(8080, $loop);
$server->listen($socket);
echo "Server running at http://127.0.0.1:8080\n";
$loop->run(); This is script runs indefinitely, serving an undefined number of requests. |
Is there any way to pass some sort of context downstream from the point
where we recieve the request to the implementation for example? A global
scope might not be possible as this is a concurrency model.
Den tir. 23. okt. 2018, 16:30 skrev Albert Casademont <
[email protected]>:
… Sure, this is taken from ReactPHP's website, for example
$loop = React\EventLoop\Factory::create();$server = new React\Http\Server(function (Psr\Http\Message\ServerRequestInterface $request) { //Lots of calls and work here return new React\Http\Response( 200, array('Content-Type' => 'text/plain'), "Hello World!\n" );});$socket = new React\Socket\Server(8080, $loop);$server->listen($socket);echo "Server running at http://127.0.0.1:8080\n";$loop->run();
This is script runs indefinitely, serving an undefined number of requests.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#214 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AC7sAoUnU6xHR90mhdAwU_y5cHOn1MtXks5unygKgaJpZM4XyobZ>
.
|
@jcchavezs yes exactly. We're right now using PHP-PM which limits concurrency for the ReactPHP loops but in theory they could be running in parallel. ReactPHP has the concept of Middlwares that let's you manipulate the request object and pass some kind of context. https://reactphp.org/http/#middleware And in theory that ReactPHP process is never killed in the sense of a traditional php request-response, so having stuff in destructors is not recommended, it might take a long time until they are executed. |
Unfortunately the current implementation of OpenCensus Tracing expects a standard isolated PHP Request lifecycle and is thus incompatible with event driven PHP solutions like ReactPHP. Given enough demand this might change in the future. OpenCensus Stats should actually work quite nicely as it allows for both implicit as well as explicit scope handling. |
Hi! Seems like the library is heavily geared towards the classic PHP single-request mode. How should I instrument my code for a ReactPHP use case? A single PHP process handles multiple requests.
Thanks!
The text was updated successfully, but these errors were encountered: