2017 © Pedro Peláez
 

library percurri

Simple client for taking to beanstlakd server

image

sunkan/percurri

Simple client for taking to beanstlakd server

  • Thursday, November 30, 2017
  • by sunkan
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Percurri

Installation

The preferred method of installing this library is with Composer by running the following from your project root:, (*1)

$ composer require sunkan/percurri

Using

Simple example

$connection = new Percurri\Connection($host, $port);
$logger = new Psr3Logger();

$workerClient = new Percurri\WorkerClient($connection, $logger);
$producerClient = new Percurri\ProducerClient($connection, $logger);

$data = 'test data';
$tube = 'test-tube';

$producerClient->tube($tube)->put($data);

$workerClient->watch($tube);
$job = $workerClient->reserve();

//do job

//then delete from beanstalkd
$workerClient->delete($job);

Api

Connection

Constructor

Connection(string $host, int $port = 11300, bool $persistent = true, int $timeout = 1)
connect(): bool
disconnect(): bool
isConnected(): bool

Read from socket.

If length is specified reads that amount from buffer otherwise looks for first newline Returns raw string from buffer, (*2)

read($length = null): string

Write to socket

You can specify a format if you want a payload formatted a specific way. Like this: write('put', $payload, "%d %d %d %d\r\n%s");, (*3)

write(string $command, array $payload, string $format = null): int

Producer client

Constructor

Logger must be an instance of a Psr3 compatible logger, (*4)

__construct(Connection $connection, LoggerInterface $logger)

Put

Priority is specified with 0 being most important and 4294967295 least important, (*5)

If no tube have been selected it puts job in to default tube, (*6)

put(string $data, int $pri = 100, int $delay = 0, int $ttr = 30): int

Select tube

tube(string $tube): self

Get current tube

currentTube(): string|bool

Pause tube

Prevent workers from reserving any new job in tube for delay seconds, (*7)

pause(string $tube, int $delay): bool

Worker client

Constructor

Logger must be an instance of a Psr3 compatible logger, (*8)

__construct(Connection $connection, LoggerInterface $logger, Factory $jobFactory, DecoderInterface $decoder)

Watch tube

Select tubes to watch. Returns number of tubes in watch list, (*9)

watch(string $tube): int

Ignore tube

Remove tube from watch list, (*10)

ignore(string $tube): int|false

List tubes watched

listTubes(): array

Reserve job

If timeout is specified will only wait that long for a job, (*11)

reserve(int $timeout = null): JobInterface

Delete job

idOrJob can either be an instance of JobInterface or an integer, (*12)

delete($idOrJob): bool

Release job

Puts a reserved job back into the ready queue., (*13)

idOrJob can either be an instance of JobInterface or an integer, (*14)

release($idOrJob, int $pri, int $delay): bool

Bury job

idOrJob can either be an instance of JobInterface or an integer, (*15)

bury($idOrJob, int $pri): bool

Touch job

Worker request more time to work on job, (*16)

idOrJob can either be an instance of JobInterface or an integer, (*17)

touch($idOrJob, int $pri): bool

Peek job

Look at job but don't reserves it, (*18)

idOrJob can either be an instance of JobInterface or an integer, (*19)

peek($idOrJob): JobInterface

Peek ready queue

peekReady(): JobInterface

Peek delayed job

peekDelayed(): JobInterface

Peek buried queue

peekBuried(): JobInterface

Kick job from buried queue

bound number of jobs to kick into ready queue, (*20)

kick(int $bound): int

Kick job

Kick job into ready queue, (*21)

idOrJob can either be an instance of JobInterface or an integer, (*22)

kickJob($idOrJob): JobInterface

Stats client

Constructor

Logger must be an instance of a Psr3 compatible logger, (*23)

__construct(Connection $connection, LoggerInterface $logger, DecoderInterface $decoder)

Stats about job

idOrJob can either be an instance of JobInterface or an integer, (*24)

statsJob($idOrJob): array

Stats about tube

statsTube(string $tube): array

Stats about system

stats(): array

List available tubes

listTubes(): array

The Versions

30/11 2017

dev-master

9999999-dev https://github.com/sunkan/percurri

Simple client for taking to beanstlakd server

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Sundqvist