maowenke/tp6-workerman-task

此包的最新版本(dev-master)没有可用的许可证信息。

tp6使用worker执行task

dev-master 2022-07-19 06:49 UTC

This package is not auto-updated.

Last update: 2024-09-24 20:48:43 UTC


README

介绍

tp6使用的worker写的异步任务模型

安装教程

  1. 使用composer命令:composer require maowenke/tp6-workerman-task dev-master

使用说明

配置config目录下的worker_task.php文件

然后在命令行中启动:php think worker:task start 监听端口

在代码中直接调用AsynchronousTaskProducer::$address=你的监听地址

然后调用AsynchronousTaskProducer::send($data,$Processing) $data为参数数组,$Processing为处理数据的类或者类名字符串 windows上为单进程,liunx上设置为多进程 处理进程的类必须实现public 的 fire方法

    public function index()
{
    AsynchronousTaskProducer::$address = '127.0.0.1:19345';
    for ($i=0;$i<10;$i++){
        $gateway_buffer = [
            'id'=>10-$i,
            'name'=>17
        ];
        $obj = "\app\index\buss\Ces";
        AsynchronousTaskProducer::send($gateway_buffer,$obj);
    }
    echo '成功';exit;
}

参与贡献

  1. 沐雨轩
  2. thinkphp