kiwfy/taurus-publisher-php 问题修复 & 功能扩展

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

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

kiwfy/taurus-publisher-php

最新稳定版本:7.0.0

Composer 安装命令:

composer require kiwfy/taurus-publisher-php

包简介

PHP library using LUA script to send for redis a job for Taurus queue

README 文档

README

Latest Version codecov CI Build Downloads Old Downloads PRs Welcome Packagist License (custom server)

PHP library using LUA script to send for redis a job for Taurus queue

Installation

Release 7.0.0 Requires PHP 8.3

Release 6.0.0 Requires PHP 8.2

Release 5.0.0 Requires PHP 8.1

Release 4.0.0 Requires PHP 7.4

Release 3.0.0 Requires PHP 7.3

Release 2.0.0 Requires PHP 7.2

Release 1.0.0 Requires PHP 7.1

The recommended way to install is through Composer.

composer require not-empty/taurus-publisher-php-lib

Usage

Publishing

use TaurusPublisher\TaurusPublisher;
$queue = 'test';
$data = [
	'publisher' => 'example',
];
$taurus = new TaurusPublisher();
$result = $taurus->add(
    $queue,
    $data
);
var_dump($result);

Publishing with redis config

use TaurusPublisher\TaurusPublisher;
$queue = 'test';
$data = [
	'publisher' => 'example',
];
$redisConfig = [
    'scheme' => 'tcp',
    'host'   => 'localhost',
    'port'   => 6379,
];
$taurus = new TaurusPublisher($redisConfig);
$result = $taurus->add(
    $queue,
    $data
);
var_dump($result);

Publishing with queue config

use TaurusPublisher\TaurusPublisher;
$queue = 'test';
$data = [
	'publisher' => 'example',
];
$taurus = new TaurusPublisher();
$queueConfig = [
    'attempts' => 4,
    'backoff' => 20000,
    'delay' => 1,
    'removeOnComplete' => 20,
];
$result = $taurus->add(
    $queue,
    $data,
    $queueConfig
);
var_dump($result);

Publishing in loop without exceed redis connections (reuse redis connections)

you may pass a redis connection to persist connection and allow you to loop add method without overload redis with connections

use TaurusPublisher\TaurusPublisher;
use Predis\Client as Redis;
$redisConfig = [
    'scheme' => 'tcp',
    'host'   => 'redis',
    'port'   => 6379,
];
$client = new Redis($redisConfig);
$queue = 'test';
$data = [
	'publisher' => 'example',
];
$taurus = new TaurusPublisher(
    $redisConfig,
    [],
    $client
);
for ($i=0; $i < 1000000; $i++) { 
    $result = $taurus->add(
        $queue,
        $data
    );
    var_dump($result);
}

if you want an environment to run or test it, you can build and install dependences like this

docker build --build-arg PHP_VERSION=8.3-rc-cli -t not-empty/taurus-publisher-php-lib:php83 -f contrib/Dockerfile .

Access the container

docker run -v ${PWD}/:/var/www/html -it not-empty/taurus-publisher-php-lib:php83 bash

Verify if all dependencies is installed

composer install --no-dev --prefer-dist

and run (you will need redis)

php sample/publisher-sample.php

Development

Want to contribute? Great!

The project using a simple code. Make a change in your file and be careful with your updates! Any new code will only be accepted with all validations.

To ensure that the entire project is fine:

First you need to building a correct environment to install all dependences

docker build --build-arg PHP_VERSION=8.3-rc-cli -t not-empty/taurus-publisher-php-lib:php83 -f contrib/Dockerfile .

Access the container

docker run -v ${PWD}/:/var/www/html -it not-empty/taurus-publisher-php-lib:php83 bash

Install all dependences

composer install --dev --prefer-dist

Run all validations

composer check

Not Empty Foundation - Free codes, full minds

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-only
  • 更新时间: 2020-07-21