/** * If the given message owns the passed in resource, then * read data on that message. * * @param Message $message * @param resource $resource * @return void */ protected function readResource(Message $message, $resource) { if ($message->getResource() === $resource) { $message->receive(); } }
/** * Remove the worker that erred and replace it. * * @param $error * @param Message $message * @return void */ public function onError($error, Message $message) { $worker = $this->getWorkerForStream($message->getResource()); if ($worker === null) { return; } $this->eventEmitter->emit('peridot.concurrency.worker.error', [$error, $worker]); $this->detach($worker); $this->broker->removeMessage($message); $worker = new Worker($this->command, $this->eventEmitter, $this->resourceOpen); $this->attach($worker); }
fseek($stream, 0); $content = fread($stream, 128); expect($content)->to->equal("last\nTERMINATE\n"); }); it('should write only a terminate single if content is omitted', function () { $this->message->end(); $stream = $this->message->getResource(); fseek($stream, 0); $content = fread($stream, 128); expect($content)->to->equal("TERMINATE\n"); }); }); describe('->getResource()', function () { it('should return the underlying resource', function () { $message = new Message($this->resource); expect($message->getResource())->to->equal($this->resource); }); }); describe('string packer accessors', function () { it('should allow access to the message string packer', function () { $packer = new StringPacker(); $this->message->setStringPacker($packer); expect($this->message->getStringPacker())->to->equal($packer); }); }); describe('broker accessors', function () { it('should allow access to the message broker', function () { $broker = new MessageBroker(); $this->message->setMessageBroker($broker); expect($this->message->getMessageBroker())->to->equal($broker); });