Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mix-php/sync-invoke
Swoole synchronous blocking code invoke library
https://github.com/mix-php/sync-invoke
Last synced: 3 months ago
JSON representation
Swoole synchronous blocking code invoke library
- Host: GitHub
- URL: https://github.com/mix-php/sync-invoke
- Owner: mix-php
- Created: 2019-11-26T10:08:15.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-10-28T04:25:57.000Z (about 4 years ago)
- Last Synced: 2024-07-12T12:43:21.276Z (4 months ago)
- Language: PHP
- Homepage:
- Size: 62.5 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-swoole - mix/sync-invoke - A library to execute synchronous blocking code without blocking the running process in Swoole. :globe_with_meridians: (Miscellaneous)
README
## Mix Sync Invoke
Swoole 同步阻塞代码调用库,用于执行无法被 Swoole Hook 协程化的同步阻塞代码
## Usage
- 安装
```
composer require mix/sync-invoke
```- Server
创建服务器,用于执行同步代码,第二个参数为 `true` 可复用端口
```
$server = new \Mix\SyncInvoke\Server(9505, true);
$server->start();
```- Client
```
$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);
```## License
Apache License Version 2.0, http://www.apache.org/licenses/