Exemplo n.º 1
0
 public function setUp()
 {
     $factory = new Factory();
     $this->recruiterDb = $factory->getMongoDb($hosts = 'localhost:27017', $options = [], $dbName = 'recruiter');
     $this->recruiterDb->drop();
     $this->repository = new Repository($this->recruiterDb);
     $this->clock = T\clock()->stop();
     $this->eventDispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
 }
Exemplo n.º 2
0
 public function setUp()
 {
     $factory = new Factory();
     $this->recruiterDb = $factory->getMongoDb($hosts = 'localhost:27017', $options = [], $dbName = 'recruiter');
     $this->cleanDb();
     $this->files = ['/tmp/recruiter.log', '/tmp/worker.log'];
     $this->cleanLogs();
     $this->roster = $this->recruiterDb->selectCollection('roster');
     $this->recruiter = new Recruiter($this->recruiterDb);
     $this->jobs = 0;
     $this->processRecruiter = null;
     $this->processCleaner = null;
     $this->processWorkers = [];
 }
Exemplo n.º 3
0
#!/usr/bin/env php
<?php 
require __DIR__ . '/../vendor/autoload.php';
use Recruiter\Recruiter;
use Recruiter\Factory;
use Recruiter\Workable\LazyBones;
use Recruiter\Worker;
use Recruiter\Option\MemoryLimit;
$factory = new Factory();
$db = $factory->getMongoDb($hosts = 'localhost:27017', $options = [], $dbName = 'recruiter');
$db->drop();
$recruiter = new Recruiter($db);
LazyBones::waitForMs(200, 100)->asJobOf($recruiter)->inGroup('mail')->inBackground()->execute();
$memoryLimit = new MemoryLimit('memory-limit', '64MB');
$worker = $recruiter->hire($memoryLimit);
$worker->workOnJobsGroupedAs('mail');
$assignments = $recruiter->assignJobsToWorkers();
$worker->work();