Exemplo n.º 1
0
 /**
  * Adds job to query
  *
  * @param string $tube tube name
  * @param string $data data to worker
  * @param int|null $ttl time to execute this job
  * @param int $priority Jobs with smaller priority values will be scheduled
  *              before jobs with larger priorities. The most urgent priority is 0;
  *              the least urgent priority is 4294967295.
  * @param int $delay delay before insert job into work query
  * @return bool
  */
 public function addJob($tube, $data, $ttl = null, $priority = 0, $delay = 0)
 {
     $ttl = $ttl ?: $this->defaultJobTtr;
     if ($tube != $this->_currTube) {
         $this->_client->useTube($tube);
         $this->_currTube = $tube;
     }
     return $this->_client->put($priority, $delay, $ttl, $data);
 }
Exemplo n.º 2
0
#!/usr/bin/env php
<?php 
use Beanstalk\Client as BeanstalkClient;
require_once __DIR__ . '/../vendor/autoload.php';
$beanstalk = new BeanstalkClient();
$beanstalk->connect();
$beanstalk->useTube('Example3');
$i = 0;
for ($i = 0; $i < 1; $i++) {
    $message = json_encode(array('id' => uniqid(md5(gethostname())), 'name' => 'Hello ' . $i));
    $result = $beanstalk->put(500, 0, 60, $message);
    echo $message . "\n";
}
$beanstalk->disconnect();
Exemplo n.º 3
0
<?php

/**
 * beanstalk: A minimalistic PHP beanstalk client.
 *
 * Copyright (c) 2009-2015 David Persson
 *
 * Distributed under the terms of the MIT License.
 * Redistributions of files must retain the above copyright notice.
 */
namespace Beanstalk;

use Beanstalk\Client;
/**
 * A small benchmark to test throughput.
 */
$connection = new Client(['host' => getenv('TEST_BEANSTALKD_HOST'), 'port' => getenv('TEST_BEANSTALKD_PORT')]);
for ($i = 0; $i < 100000; $i++) {
    $connection->put(1024, 0, 60, $i);
}
Exemplo n.º 4
0
 protected function _error($message)
 {
     parent::_error($message);
     $this->_latestError = $message;
 }