php-k8s icon indicating copy to clipboard operation
php-k8s copied to clipboard

use app default event loop for websocket calls

Open petli-full opened this issue 1 year ago • 1 comments

For websocket calls, instead of creating a new event loop, it's better using the default one. This allows other IO events can be attached to the same event loop and act on each other accordingly. For example (pseudo code),

// signal a pod by another IO event
$conn = null;

$pod->attach(function (WebSocket $connection) use (&$conn) {
    $conn = $connection;
    ......
});

$loop->addTimer(0.8, function () use (&$conn) {
    if ($conn) $conn->send('0123456789');
});

Besides, it is recommended by ReactPHP. The create method has been deprecated: https://github.com/reactphp/event-loop/blob/1.x/src/Factory.php#L13-L34

petli-full avatar Oct 11 '23 16:10 petli-full

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 94.17%. Comparing base (046c682) to head (fcbe038). Report is 10 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #390   +/-   ##
=========================================
  Coverage     94.17%   94.17%           
  Complexity      700      700           
=========================================
  Files            70       70           
  Lines          1837     1837           
=========================================
  Hits           1730     1730           
  Misses          107      107           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Oct 11 '23 20:10 codecov[bot]