setId() public méthode

Set the ID of this worker to a given ID string.
public setId ( string $workerId )
$workerId string ID for the worker.
Exemple #1
0
 public function testDeadWorkerCleanUpDoesNotCleanUnknownWorkers()
 {
     // Register a bad worker on this machine
     $worker = new Resque_Worker('jobs');
     $worker->setLogger(new Resque_Log());
     $workerId = explode(':', $worker);
     $worker->setId($workerId[0] . ':1:jobs');
     $worker->registerWorker();
     // Register some other false workers
     $worker = new Resque_Worker('jobs');
     $worker->setLogger(new Resque_Log());
     $worker->setId('my.other.host:1:jobs');
     $worker->registerWorker();
     $this->assertEquals(2, count(Resque_Worker::all()));
     $worker->pruneDeadWorkers();
     // my.other.host should be left
     $workers = Resque_Worker::all();
     $this->assertEquals(1, count($workers));
     $this->assertEquals((string) $worker, (string) $workers[0]);
 }
Exemple #2
0
 /**
  * Remove a worker
  * @param  string $id tring identifying this worker
  * @return bool
  */
 public function removeWorker($id)
 {
     $worker = new \Resque_Worker('*');
     $worker->setId($id);
     return $worker->unregisterWorker();
 }