dev-master
9999999-dev https://github.com/sunkan/percurriSimple client for taking to beanstlakd server
MIT
The Requires
- php >=7.0.0
- psr/log ~1.0
The Development Requires
by Andreas Sundqvist
Simple client for taking to beanstlakd server
The preferred method of installing this library is with Composer by running the following from your project root:, (*1)
$ composer require sunkan/percurri
$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);
Connection(string $host, int $port = 11300, bool $persistent = true, int $timeout = 1)
connect(): bool disconnect(): bool isConnected(): bool
If length is specified reads that amount from buffer otherwise looks for first newline Returns raw string from buffer, (*2)
read($length = null): string
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
Logger must be an instance of a Psr3 compatible logger, (*4)
__construct(Connection $connection, LoggerInterface $logger)
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
tube(string $tube): self
currentTube(): string|bool
Prevent workers from reserving any new job in tube for delay
seconds, (*7)
pause(string $tube, int $delay): bool
Logger must be an instance of a Psr3 compatible logger, (*8)
__construct(Connection $connection, LoggerInterface $logger, Factory $jobFactory, DecoderInterface $decoder)
Select tubes to watch. Returns number of tubes in watch list, (*9)
watch(string $tube): int
Remove tube from watch list, (*10)
ignore(string $tube): int|false
listTubes(): array
If timeout is specified will only wait that long for a job, (*11)
reserve(int $timeout = null): JobInterface
idOrJob
can either be an instance of JobInterface
or an integer
, (*12)
delete($idOrJob): bool
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
idOrJob
can either be an instance of JobInterface
or an integer
, (*15)
bury($idOrJob, int $pri): bool
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
Look at job but don't reserves it, (*18)
idOrJob
can either be an instance of JobInterface
or an integer
, (*19)
peek($idOrJob): JobInterface
peekReady(): JobInterface
peekDelayed(): JobInterface
peekBuried(): JobInterface
bound
number of jobs to kick into ready queue, (*20)
kick(int $bound): int
Kick job into ready queue, (*21)
idOrJob
can either be an instance of JobInterface
or an integer
, (*22)
kickJob($idOrJob): JobInterface
Logger must be an instance of a Psr3 compatible logger, (*23)
__construct(Connection $connection, LoggerInterface $logger, DecoderInterface $decoder)
idOrJob
can either be an instance of JobInterface
or an integer
, (*24)
statsJob($idOrJob): array
statsTube(string $tube): array
stats(): array
listTubes(): array
Simple client for taking to beanstlakd server
MIT