/** * 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; }
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); }); }
/** * @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()); }
/** * {@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); }); }
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); }