All Projects → Littlesqx → Aint Queue

Littlesqx / Aint Queue

Licence: mit
🚀 An async-queue library built on top of swoole, flexable multi-consumer, coroutine supported. 基于 Swoole 的一个异步队列库,可弹性伸缩的工作进程池,工作进程协程支持。

Projects that are alternatives of or similar to Aint Queue

Ytask
YTask is an asynchronous task queue for handling distributed jobs in golang(go异步任务框架)
Stars: ✭ 121 (-15.38%)
Mutual labels:  job, worker, queue
wtsqs
Simplified Node AWS SQS Worker Wrapper
Stars: ✭ 18 (-87.41%)
Mutual labels:  queue, job, worker
Arq
Fast job queuing and RPC in python with asyncio and redis.
Stars: ✭ 695 (+386.01%)
Mutual labels:  async, worker, queue
Workq
Job server in Go
Stars: ✭ 1,546 (+981.12%)
Mutual labels:  job, worker, queue
Saber
⚔️ Saber, PHP异步协程HTTP客户端 | PHP Coroutine HTTP client - Swoole Humanization Library
Stars: ✭ 866 (+505.59%)
Mutual labels:  async, coroutine, swoole
Swpdo
Swoole Coroutine SQL component like PDO | 0成本迁移PDO到Swoole高性能协程客户端
Stars: ✭ 64 (-55.24%)
Mutual labels:  coroutine, swoole
Swoft Framework
[READ ONLY] Swoft Framework, base of Swoft
Stars: ✭ 70 (-51.05%)
Mutual labels:  coroutine, swoole
Php Coroutine Engine
This project for php-fpm support coroutine
Stars: ✭ 74 (-48.25%)
Mutual labels:  coroutine, swoole
Laravel Elasticbeanstalk Queue Worker
Stars: ✭ 48 (-66.43%)
Mutual labels:  worker, queue
Ycsocket
基于swoole的socket框架,支持协程版MySQL、Redis连接池,已用于大型RPG游戏服务端
Stars: ✭ 77 (-46.15%)
Mutual labels:  coroutine, swoole
Yii2 Swoole
full solutions making yii2-framework run on swoole with coroutine.
Stars: ✭ 86 (-39.86%)
Mutual labels:  coroutine, swoole
Unityasync
Task and Async Utility Package for Unity. Start co-routines from anywhere.
Stars: ✭ 58 (-59.44%)
Mutual labels:  async, coroutine
Tossit
Library for distributed job/worker logic.
Stars: ✭ 56 (-60.84%)
Mutual labels:  job, worker
Traffic Shm
traffic-shm (Anna) is a Java based lock free IPC library.
Stars: ✭ 72 (-49.65%)
Mutual labels:  async, queue
Tasktiger
Python task queue using Redis
Stars: ✭ 1,053 (+636.36%)
Mutual labels:  worker, queue
Bull
Premium Queue package for handling distributed jobs and messages in NodeJS.
Stars: ✭ 11,748 (+8115.38%)
Mutual labels:  job, queue
Simpleue
PHP queue worker and consumer - Ready for AWS SQS, Redis, Beanstalkd and others.
Stars: ✭ 124 (-13.29%)
Mutual labels:  worker, queue
Mix
☄️ PHP CLI mode development framework, supports Swoole, WorkerMan, FPM, CLI-Server / PHP 命令行模式开发框架,支持 Swoole、WorkerMan、FPM、CLI-Server
Stars: ✭ 1,753 (+1125.87%)
Mutual labels:  coroutine, swoole
Archer
基于协程Swoole的Task组件,支持多种模式。轻松实现协程Task的队列、并发、Defer、计时器等 | Swoole coroutine task kit - Swoole Humanization Library
Stars: ✭ 132 (-7.69%)
Mutual labels:  coroutine, swoole
Sidekiq Job Php
Push and schedule jobs to Sidekiq from PHP
Stars: ✭ 34 (-76.22%)
Mutual labels:  worker, queue

Aint Queue

Build Status License Php version Version

An async-queue library built on top of swoole, flexible multi-consumer, coroutine supported. 中文说明

queue_status.gif

Feature

  • Default Redis driver
  • Delayed job
  • The custom job retries and times
  • Custom failed callback
  • Job middleware
  • Queue snapshot event
  • Concurrent processing, flexible multi-worker
  • Worker coroutine support
  • Beautiful dashboard

Required

  • PHP 7.2+
  • Swoole 4.4+
  • Redis 3.2+ (redis driver)

Install

composer require littlesqx/aint-queue -vvv

Usage

Config

By default, aint-queue will require config/aint-queue.php as default config. If not exist, /vendor/littlesqx/aint-queue/src/Config/config.php will be the final config file.

<?php

use Littlesqx\AintQueue\Driver\Redis\Queue as RedisQueue;
use Littlesqx\AintQueue\Logger\DefaultLogger;

return [
    // channel_name => [...config]
    'default' => [
        'driver' => [
            'class' => RedisQueue::class,
            'connection' => [
                'host' => '127.0.0.1',
                'port' => 6379,
                'database' => '0',
                // 'password' => 'password',
            ],
        ],
        'logger' => [
            'class' => DefaultLogger::class,
            'options' => [
                'level' => \Monolog\Logger::DEBUG,
            ],
        ],
        'pid_path' => '/var/run/aint-queue',
        'consumer' => [
            'sleep_seconds' => 1,
            'memory_limit' => 96,
            'dynamic_mode' => true,
            'capacity' => 6,
            'flex_interval' => 5 * 60,
            'min_worker_number' => 5,
            'max_worker_number' => 30,
            'max_handle_number' => 0,
        ],
        'job_snapshot' => [
            'interval' => 5 * 60,
            'handler' => [],
        ],
    ],
];

All the options:

name type comment default
channel string The queue unit, every queue pusher and queue listener work for. Multiple channel supported, use --channel option. default
driver.class string Queue driver class, implements QueueInterface. Redis
driver.connection map Queue driver's config.
pid_path string The path of listener master pid file. Noted that permission required. /var/run/aint-queue
consumer.sleep_seconds int Sleep seconds after every empty pop from queue. 1
consumer.memory_limit int Mb. Worker will reload when its memory usage exceeds the limit. 96
consumer.dynamic_mode bool Determine whether worker's number flex dynamically. true
consumer.capacity int The capacity that every consumer can handle in health and in short time, it affects the worker number when dynamic-mode. 5
consumer.flex_interval int every flex_interval seconds monitor process try to flex the worker number. Only work when consumer.dynamic_mode = true. 5
consumer.min_worker_number int Min expansion. 5
consumer.max_worker_number int Max expansion. 30
consumer.max_handle_number int Current consumer's max job-handle time. 0 means no limit. 0
job_snapshot map Every interval seconds, handles will be executed. Handle must implements JobSnapshotterInterface.

Push job

You can use it in your project running via fpm/cli.

<?php

use Littlesqx\AintQueue\Driver\DriverFactory;

$queue = DriverFactory::make($channel, $options);

// push a job
$queue->push(function () {
    echo "Hello aint-queue\n";
});

// push a delay job
$closureJob = function () {
    echo "Hello aint-queue delayed\n";
};
$queue->push($closureJob, 5);

// And class job are allowed.
// 1. Create a class which implements JobInterface, you can see the example in `/example`.
// 2. Noted that job pushed should be un-serialize by queue-listener,
//    it means queue-pusher and queue-listener are required to in the same project.                                          
// 3. You can see more examples in `example` directory.

Manage Queue

We recommend that using Supervisor to monitor and control the listener.

vendor/bin/aint-queue
AintQueue Console Tool

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  help                 Displays help for a command
  list                 Lists commands
 queue
  queue:clear          Clear the queue.
  queue:dashboard      Start http server for dashboard.
  queue:reload-failed  Reload all the failed jobs onto the waiting queue.
  queue:status         Get the execute status of specific queue.
 worker
  worker:listen        Listen the queue.
  worker:reload        Reload worker for the queue.
  worker:run           Run the specific job.
  worker:stop          Stop listening the queue.

Testing

composer test

Contributing

You can contribute in one of three ways:

  1. File bug reports using the issue tracker.
  2. Answer questions or fix bugs on the issue tracker.
  3. Contribute new features or update the wiki.

The code contribution process is not very formal. You just need to make sure that you follow the PSR-2, PSR-12 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].