Ejemplo n.º 1
0
 /**
  * Configure the producer
  *
  * @param              $topic
  * @param VectorInterface $channels
  * @param MapInterface $configs
  */
 protected function configureChannels($topic, VectorInterface $channels, MapInterface $configs)
 {
     $channels->each(function (AMQPChannel $channel) use($topic, $configs) {
         $channel->queue_declare($topic, $configs->get('passive'), $configs->get('durable'), $configs->get('exclusive'), $configs->get('auto_delete'), $configs->get('nowait'), $configs->get('arguments'), $configs->get('ticket'));
     });
     $this->configured = true;
 }
Ejemplo n.º 2
0
 private function processEvent(DomainEventInterface $event)
 {
     $this->eventListeners->filter(function (EventListenerInterface $eventListener) use($event) {
         return $eventListener->isSubscribedTo($event);
     })->each(function (EventListenerInterface $eventListener) use($event) {
         $eventListener->handle($event);
     });
 }
Ejemplo n.º 3
0
 /**
  * @test
  */
 public function is_should_concatenate_vectors()
 {
     if ($this->coll instanceof MapInterface) {
         $this->coll->add(new Pair(0, 1))->add(new Pair(1, 2))->add(new Pair(3, 4));
     } else {
         $this->coll->add(1)->add(2)->add(4);
     }
     $coll2 = new Vector([3]);
     $concatenated = $this->coll->concat($coll2);
     $this->assertEquals([1, 2, 4, 3], $concatenated->toArray());
 }
Ejemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function produce($payload, $configs = [])
 {
     $configs = new Dictionary($configs);
     $this->producers->each(function (ProducerInterface $producer) use($payload, $configs) {
         /** @var MapInterface $brokerConfigs */
         $brokerConfigs = $configs->get($producer->getName());
         try {
             $topic = $brokerConfigs->get('topic');
         } catch (\OutOfBoundsException $e) {
             throw new \InvalidArgumentException('You should configure the topic/exchange that you want to produce to');
         }
         $producer->produce($topic, $payload, $brokerConfigs);
     });
 }
Ejemplo n.º 5
0
 public function serializeCollection(VisitorInterface $visitor, VectorInterface $collection, array $type, Context $context)
 {
     // We change the base type, and pass through possible parameters.
     $type['name'] = 'array';
     return $visitor->visitArray($collection->toArray(), $type, $context);
 }