承接 ozaretskii/php-snake-mqp 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

ozaretskii/php-snake-mqp

Composer 安装命令:

composer require ozaretskii/php-snake-mqp

包简介

PHP async messages queueing and processing library

README 文档

README

SnakeMQP is a library for running and managing php tasks asynchronously via queues. You can simpy integrate async execution any part of your code with just a couple of minutes of work. This library provides you with all necessary tools to just start enjoying aync tasks processing out of the box, or building more complex and scalable task management system on top of it.

Ofter our code execution require more time or resources that we can afford on per same http request basis. In that case moving parts of most heavy or time-consuming operations on background can be an obvious solution. Background execution allows you to process multiple tasks per same time by using multiple workers, or simultaneous "chain" (placing next task to queue after current is finished) tasks execution, when an order of execution is critically important.

You can simply manage many types of your tasks by placing them into separated queue names and assigning priorities for any specific task or a queue. Delayed execution can also be handy in some specific cases. Dedicated workers for processing specific queue names can allow you to immediately process important tasks besides other queues to make sure that critically important parts of your project is always running on time.

SnakeMQP allows you to make any number and type of independent "workers" that can be called from project code, cli or rest api. That means you can integrate asynchronous execution of any part of your code even been limited to low level server access. Your workers can be triggered by simple crontab script, CURL, external authorized API call or unix daemon (like Supervisor or Systemd).

Benefits of using SnakeMQP:

  • Easy integration in any php based project
  • Highly manageable queueing system
  • Delayed execution of tasks
  • Having a dedicated workers to process specific queues or tasks with specific priority only
  • Dynamic integration of "workers" to meet your project needs

Quick Examples

Placing tasks for further processing (mysql based queue)

<?php
// Require the Composer autoloader.
require 'vendor/autoload.php';

use Ozaretskii\PhpSnakeMqp\adapters\MysqlQueueAdapter;
use Ozaretskii\PhpSnakeMqp\SnakeClient;

// Initiate queue adapter
$adapter = new MysqlQueueAdapter([
    'host' => 'localhost',
    'user' => 'root',
    'password' => 'root',
    'database' => 'test_database',
    'port' => '',
    'socket' => '',
]);
// create table if not existing yet (can be called just once per lifetime).
$adapter->prepare();
// Placing tasks into the queue
$hello = function ($arg1, $arg2) {
    var_dump($arg1);
    return $arg2;
};
$client = new SnakeClient($adapter);
// queueing closure
$client->addQueue($hello, ['function output', 'function result']);
/**
 * Worker:
 * - output: string(15) "function output"
 * - result: "function result"
 */
// queueing regular function
$client->addQueue('var_dump', ['text1', ['data' => 'array']]);
/** Worker:
 * - output: 
 * string(5) "text1"
 * array(1) {
 *   ["data"]=> string(5) "array"
 * } 
 * - result: null
 */

Running worker (mysql based queue)

<?php
// Initiate queue adapter
$adapter = new MysqlQueueAdapter([
    'host' => 'localhost',
    'user' => 'root',
    'password' => 'root',
    'database' => 'test_database',
    'port' => '',
    'socket' => '',
]);
// process 10 jobs from the queue and print results
foreach ($client->processJobsInQueue(10) as $job) {
    if ($job->isSuccessful()) {
        var_dump("Job $job->id has finished.");
        var_dump("Results: ", $job->result);
        var_dump("Output: ", $job->printedOutput);
    } else {
        var_dump("Job $job->id has failed with an error.");
        var_dump("Error: ", $job->result);
        var_dump("Output: ", $job->printedOutput);
    }
}

Getting Help

If you encounter a bug, need help with implementing SnakeMQP into your project, or you need to request an extra functionality into the library - feel free submitting any issues on https://github.com/ozaretskii/php-snake-mqp/issues . Any PR's are welcome. I hope it will help you with your needs. Thanks.

ozaretskii/php-snake-mqp 适用场景与选型建议

ozaretskii/php-snake-mqp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 07 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 ozaretskii/php-snake-mqp 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2022-07-20