xobotyi/beansclient 问题修复 & 功能扩展

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

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

xobotyi/beansclient

最新稳定版本:v3.0.0-alpha.1

Composer 安装命令:

composer require xobotyi/beansclient

包简介

PHP7.1+ client for beanstalkd work queue with no dependencies

README 文档

README

beansclient

NPM Version NPM Downloads NPM Dependents Build Coverage NPM Dependents NPM Dependents

About

BeansClient is a PHP8 client for beanstalkd work queue with thorough unit-testing. Library uses PSR-4 autoloader standard and always has 100% tests coverage.
Library gives you a simple way to provide your own Socket implementation, in cases when you need to log requests and responses or to proxy traffic to non-standard transport.

BeansClient supports whole bunch of commands and responses specified in protocol for version 1.12

Why BeansClient?

  1. Well tested.
  2. Supports UNIX sockets.
  3. Actively maintained.
  4. Predictable (does not throw exception in any situation, hello pheanstalk🤪).
  5. PHP8 support.

Contents

  1. Requirements
  2. Installation
  3. Usage
  4. Docs
    • TBD

Requirements

Installation

Install with composer

composer require xobotyi/beansclient

Usage

<?php
use xobotyi\beansclient\Beanstalkd;
use xobotyi\beansclient\Client;
use xobotyi\beansclient\Socket\SocketsSocket;

$sock   = new SocketsSocket(host: 'localhost', port: 11300, connectionTimeout: 2);
$client = new Client(socket: $sock, defaultTube: 'myAwesomeTube');

##            ##
#   PRODUCER   #
##            ##

$job = $client->put("job's payload", delay: 2);
if($job['state'] === Beanstalkd::JOB_STATE_DELAYED) {
  echo "Job {$job['id']} is ready to be reserved within 2 seconds\n";
}

##            ##
#    WORKER    #
##            ##

$client->watchTube('myAwesomeTube2');

$job = $client->reserve();

if ($job) {
    echo "Hey, i received first {$job['payload']} of job with id {$job['id']}\n";

    $client->delete($job['id']);

    echo "And i've done it!\n";
}
else {
    echo "So sad, i have nothing to do";
}

echo "Am I still connected? \n" . ($client->socket()->isConnected() ? 'Yes' : 'No') . "\n";

统计信息

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

GitHub 信息

  • Stars: 92
  • Watchers: 7
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-03-16