/** * @param $workers */ protected function registerWatchers($workers) { array_map(function (\Beanie\Worker $worker) { $worker->getTubeStatus()->setWatchedTubes($this->config->getWatchedTubes()); $this->eventLoop->registerJobListener($worker); }, $workers); $this->eventLoop->registerBreakCondition('time to live', [$this, 'checkTimeToLive'])->registerBreakCondition('maximal memory usage', [$this, 'checkMaximalMemoryUsage']); array_map(function ($terminationSignal) { $this->eventLoop->registerBreakSignal($terminationSignal); }, $this->config->getTerminationSignals()); }
/** * @param EventLoop $eventLoop * @return $this */ public function withEventLoop(EventLoop $eventLoop) { $eventLoop->setLogger($this->logger); $this->eventLoop = $eventLoop; return $this; }
public function testDestructor_stopsAllWatchers() { $watchers = []; $watchers[] = $this->getWatcherMock(['stop']); $watchers[] = $this->getWatcherMock(['stop']); $watchers[] = $this->getWatcherMock(['stop']); $eventLoop = new EventLoop(); array_map(function ($watcher) use($eventLoop) { /** @var \PHPUnit_Framework_MockObject_MockObject|WatcherMock $watcher */ $watcher->expects($this->atLeastOnce())->method('stop')->willReturn(true); $eventLoop->registerWatcher($watcher); }, $watchers); $eventLoop->__destruct(); }