-
-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathCallableRunner.php
More file actions
37 lines (28 loc) · 813 Bytes
/
CallableRunner.php
File metadata and controls
37 lines (28 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace Runtime\Swoole;
use Symfony\Component\Runtime\RunnerInterface;
/**
* A simple runner that will run a callable.
*
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
class CallableRunner implements RunnerInterface
{
use SwooleEventsTrait;
/** @var ServerFactory */
private $serverFactory;
/** @var callable */
private $application;
public function __construct(ServerFactory $serverFactory, callable $application)
{
$this->serverFactory = $serverFactory;
$this->application = $application;
}
public function run(): int
{
$server = $this->serverFactory->createServer($this->application);
$this->registerSwooleEvents($server, $this->serverFactory->getOptions());
$server->start();
return 0;
}
}