mix / sync-invoke
Swoole 同步阻塞代码调用库
v2.2.16
2020-10-27 07:56 UTC
Requires
- php: >=7.0.0
- ext-swoole: >=4.4.4
- mix/bean: ~2.2.0
- mix/object-pool: ~2.2.0
- mix/server: ~2.2.0
- opis/closure: ^3.5
- psr/event-dispatcher: ^1.0
Requires (Dev)
- phpunit/phpunit: ^7.0.0
This package is auto-updated.
Last update: 2024-08-28 12:48:20 UTC
README
Swoole 同步阻塞代码调用库,用于执行无法被 Swoole Hook 协程化的同步阻塞代码
用法
- 安装
composer require mix/sync-invoke
- 服务器
创建服务器,用于执行同步代码,第二个参数为 true
可复用端口
$server = new \Mix\SyncInvoke\Server(9505, true);
$server->start();
- 客户端
$dialer = new \Mix\SyncInvoke\Client\Dialer();
$client = $dialer->dial(9505);
$data = $client->invoke(function () {
$obj = new Hello();
return [1, 2, 3, $obj];
});
var_dump($data);
许可证
Apache 许可证版本 2.0, https://apache.ac.cn/licenses/