Example #1
0
 /**
  * @return void
  */
 protected function init()
 {
     $this->logger->info("Running " . self::class . " on " . str_replace("\n", "", `hostname; echo ' - ';uname -a;`));
     $this->logger->info("The eviction tick rate is set to {$this->config->getEvictionTicksPerSec()}/second.");
     // Create the event loop
     $this->reactLoop = React\EventLoop\Factory::create();
     // Object pool
     $this->queue = new PriorityHashQueue();
     // In default mode the latest data will be replaced for a given key. In DATA_MODE_APPEND the data will be appended
     // internally and available within the consumer as array (for instance for reducing purposes)
     //$this->queue->setDataMode(PriorityHashQueue::DATA_MODE_APPEND);
     // Setup ZMQ to send evicted objects.
     $this->zmqContext = new React\ZMQ\Context($this->reactLoop);
     $this->logger->info("Binding inbound ZMQ to '{$this->config->getZmqIn()}'.");
     // Receiver queue for incoming objects
     $this->zmqInboundQueue = $this->zmqContext->getSocket(\ZMQ::SOCKET_PULL);
     $this->zmqInboundQueue->bind($this->config->getZmqIn());
     $this->logger->info("Binding outbound ZMQ to '{$this->config->getZmqOut()}'.");
     // Outgoing queue for evicted objects
     $this->zmqOutboundQueue = $this->zmqContext->getSocket(\ZMQ::SOCKET_PUSH);
     $this->zmqOutboundQueue->bind($this->config->getZmqOut());
     // Register events
     $this->registerInboundEvents();
     $this->registerEvictionEvents();
     $this->registerTimedEvents();
 }