ywna/swbt 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ywna/swbt

Composer 安装命令:

composer require ywna/swbt

包简介

A PHP Framework of swoole with beanstalkd

README 文档

README

SWBT

Github Releases Packagist GitHub commits GitHub release

A PHP Framework of swoole with beanstalkd

Install beanstalkd

Install Swoole

  • sudo apt-get install -y php-pear php7.0-dev
  • sudo pecl install swoole
  • Swoole仅支持 Linux、FreeBSD、MacOS 三种操作系统(在Windows平台,可使用CygWin或WSL(Windows Subsystem for Linux)),因此基于Swoole的SWBT同样无法在Windows系统下运行
  • Doc

Install SWBT

  • Composer安装
    composer config bin-dir bin
    composer require ywna/swbt
    

Start-Up(作为第三方依赖)

  • 消息队列的状态
    vendor/bin/SWBT status
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"hostname":"chenbo-Vostro-3559","id":"c53887df34bcd127","job-timeouts":"0","pid":"1113","total-connections":"3","total-jobs":"0","uptime":"31447","version":"1.9"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"current-jobs-urgent":"15","des":"优先级小于1024状态为ready的job数量"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"current-jobs-ready":"39","des":"状态为ready的job数量"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"current-jobs-reserved":"0","des":"状态为reserved的job数量"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"current-jobs-delayed":"0","des":"状态为delayed的job数量"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"current-jobs-buried":"2","des":"状态为buried的job数量"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"cmd-put":"0","des":"总共执行put指令的次数"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"cmd-peek":"0","des":"总共执行peek指令的次数"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"cmd-peek-ready":"0","des":"总共执行peek-ready指令的次数"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"cmd-peek-delayed":"0","des":"总共执行peek-delayed指令的次数"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"cmd-peek-buried":"0","des":"总共执行peek-buried指令的次数"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"cmd-reserve":"0","des":"总共执行reserve指令的次数"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"cmd-reserve-with-timeout":"0","des":"总共执行reserve-with-timeout指令的次数"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"cmd-delete":"0","des":"总共执行delete指令的次数"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"cmd-release":"0","des":"总共执行release指令的次数"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"cmd-use":"0","des":"总共执行use指令的次数"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"cmd-watch":"0","des":"总共执行watch指令的次数"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"cmd-ignore":"0","des":"总共执行ignore指令的次数"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"cmd-bury":"0","des":"总共执行bury指令的次数"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"cmd-kick":"0","des":"总共执行kick指令的次数"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"cmd-touch":"0","des":"总共执行touch指令的次数"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"cmd-stats":"3","des":"总共执行stats指令的次数"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"cmd-stats-job":"0","des":"总共执行stats-job指令的次数"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"cmd-stats-tube":"0","des":"总共执行stats-tube指令的次数"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"cmd-list-tubes":"0","des":"总共执行list-tubes指令的次数"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"cmd-list-tube-used":"0","des":"总共执行list-tube-used指令的次数"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"cmd-list-tubes-watched":"0","des":"总共执行list-tubes-watched指令的次数"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"cmd-pause-tube":"0","des":"总共执行pause-tube指令的次数"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"max-job-size":"5242880","des":"job的数据部分最大长度"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"current-tubes":"5","des":"当前存在的tube数量"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"current-connections":"1","des":"当前打开的连接数"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"current-producers":"0","des":"当前所有的打开的连接中至少执行一次put指令的连接数量"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"current-workers":"0","des":"当前所有的打开的连接中至少执行一次reserve指令的连接数量"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"current-waiting":"0","des":"当前所有的打开的连接中执行reserve指令但是未响应的连接数量"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"rusage-utime":"0.000000","des":"进程总共占用的用户CPU时间"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"rusage-stime":"0.003083","des":"进程总共占用的系统CPU时间"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"binlog-oldest-index":"118","des":"开始储存jobs的binlog索引号"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"binlog-current-index":"123","des":"当前储存jobs的binlog索引号"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"binlog-records-migrated":"0","des":"is the cumulative number of records written as part of compaction."} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"binlog-records-written":"0","des":"binlog累积写入的记录数"} []
    [2018-06-25 17:46:04] SWBT.INFO: Status Info: {"binlog-max-size":"10485760","des":"binlog的最大容量"} []
    
  • 消息队列的Job状态信息
    vendor/bin/SWBT status-job
    [2018-06-25 17:39:20] SWBT.INFO: Status Info: {"hostname":"chenbo-Vostro-3559","id":"c53887df34bcd127","job-timeouts":"0","pid":"1113","total-connections":"2","total-jobs":"0","uptime":"31043","version":"1.9"} []
    [2018-06-25 17:39:20] SWBT.INFO: Status Info: {"current-jobs-urgent":"15","des":"优先级小于1024状态为ready的job数量"} []
    [2018-06-25 17:39:20] SWBT.INFO: Status Info: {"current-jobs-ready":"39","des":"状态为ready的job数量"} []
    [2018-06-25 17:39:20] SWBT.INFO: Status Info: {"current-jobs-reserved":"0","des":"状态为reserved的job数量"} []
    [2018-06-25 17:39:20] SWBT.INFO: Status Info: {"current-jobs-delayed":"0","des":"状态为delayed的job数量"} []
    [2018-06-25 17:39:20] SWBT.INFO: Status Info: {"current-jobs-buried":"2","des":"状态为buried的job数量"} []
    
  • bash端方式
    vendor/bin/SWBT run
    
  • 守护进程deamon方式
    vendor/bin/SWBT start
    
  • 停止
    vendor/bin/SWBT stop
    
  • 队列管道配置
    swb/config/SWBT.php
    
    return [
        'tubes' => [
            //队列处理管道名称
            'test' => [
                'worker_num' => 3, //处理进程数量
                'class' => \SWBT\Worker\TestWorker::class //队列处理类
            ]
        ]
    ];
    
  • 队列处理类模板,继承BaseWorker类和Worker接口
        <?php
        
        namespace Monkey\Worker;
    
        use SWBT\Code;
        use SWBT\Worker\BaseWorker;
        use SWBT\Worker\Worker;
    
        class TestWorker extends BaseWorker implements Worker
        {
            public function handleJob()
            {
                echo 'do something';
                return ['code'=>Code::$success];
                // return ['code'=>Code::$delayed];
                // return ['code'=>Code::$buried];
            }
        }
    

Start-Up(独立项目运行)

  • bash端方式
    bin/SWBT run
    
  • 守护进程deamon方式
    bin/SWBT start
    
  • 停止
    bin/SWBT stop
    
  • 队列管道配置(同上)
  • 队列处理类:src/Worker
  • 目录storage可读写

ywna/swbt 适用场景与选型建议

ywna/swbt 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 335 次下载、GitHub Stars 达 20, 最近一次更新时间为 2018 年 06 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「queue」 「php」 「beanstalkd」 「swoole」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 ywna/swbt 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ywna/swbt 我们能提供哪些服务?
定制开发 / 二次开发

基于 ywna/swbt 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 335
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 20
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 20
  • Watchers: 2
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2018-06-05