xobotyi / beansclient
PHP7.1+ client for beanstalkd work queue with no dependencies
Fund package maintenance!
Patreon
Installs: 23 799
Dependents: 0
Suggesters: 0
Security: 0
Stars: 91
Watchers: 8
Forks: 10
Open Issues: 3
Requires
- php: >=8
- ext-json: *
- ext-mbstring: *
- ext-sockets: *
Requires (Dev)
- phpunit/phpunit: 9.5.8
- dev-master
- v3.0.0-alpha.1
- v2.0.0-alpha.13
- v2.0.0-alpha.12
- v2.0.0-alpha.11
- v2.0.0-alpha.10
- v2.0.0-alpha.9
- v2.0.0-alpha.8
- v2.0.0-alpha.7
- v2.0.0-alpha.6
- v2.0.0-alpha.5
- v2.0.0-alpha.4
- v2.0.0-alpha.3
- v2.0.0-alpha.2
- v2.0.0-alpha.1
- v1.0.1
- v1.0.0
- v1.0.0-RC1
- v0.9.2
- v0.9.1
- v0.9.0
- dev-dependabot/composer/phpunit/phpunit-9.6.5
- dev-dependabot/github_actions/fastify/github-action-merge-dependabot-3.6.1
- dev-3.x-dev
- dev-2.x-dev
This package is auto-updated.
Last update: 2024-12-10 04:41:44 UTC
README
beansclient
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?
- Well tested.
- Supports UNIX sockets.
- Actively maintained.
- Predictable (does not throw exception in any situation, hello
pheanstalk
🤪). - PHP8 support.
Contents
Requirements
- PHP 8.0+
- beanstalkd 1.12+
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";