1 Unstar Star 0 Fork 0

天蝎儿 / swoole多进程行务PHP

Create your Gitee Account
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
Nothing here. spread retract

Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

#多进程任务处理

架构图

架构图

要求/扩展 说明
php>7.1 支持php>7.1
swoole 需使用 swoole >= 4.4.15
sysvmsg 需安装php sysvmsg扩展
posix 需安装 php poix扩展

工具说明

基于swoole process 进程实现多任务处理,可实现socket及sysvmsg任务投递 也可做socket文件上传,可动态增加或减少woker处理进程

socket 分包

#使用前四个字节标注信息长度
function packs($message){
    $fooLenn = pack("N", strlen($message));
    $package = $fooLenn . $message;
    return $package;
}

使用

创建服务端

define('ROOT', __DIR__);
require_once ROOT."/Core/Worker.php";
#参数依次为  ip地址  端口  进程名称(不能使用中文)
$worker = new Worker('0.0.0.0', 9515, 'myWorkName');
$worker->onAcceptFinish= function($res){
    $resInt = (int)$res;
    echo '接收完成'.$resInt.PHP_EOL;
};
$worker->onWorker = function ($wokerId, $messageType, $message){
    echo 'workerId:'.$wokerId.',messageType:'.$messageType.',message:'.$message.PHP_EOL;
};
$worker->run();

Comments ( 0 )

Sign in for post a comment

PHP
1
https://gitee.com/kelley0827/swote_multi_process_operation.git
git@gitee.com:kelley0827/swote_multi_process_operation.git
kelley0827
swote_multi_process_operation
swoole多进程行务
master

Search

131423 f1aaba0b 1899542 094922 1c74bed3 1899542