get() 공개 메소드

public get ( $key )
 /**
  * Busca por uma estratégia a partir do nome definido para a mesma.
  * @param $name
  * @return mixed
  * @throws StrategyNotFoundException
  */
 public function getStrategy($name)
 {
     if (!$this->dictionary->containsKey($name)) {
         throw new StrategyNotFoundException();
     }
     return $this->dictionary->get($name);
 }
예제 #2
0
 /**
  * @param $service
  * @return ServiceInterface
  */
 public function getService($service)
 {
     //Lazy authentication
     $token = $this->authenticationService->getAccessToken();
     if (!$token->getAccessToken()) {
         $this->authenticationService->authorize();
     }
     $this->client->createClient($this->authenticationService->getConsumerId(), $token->getAccessToken());
     return $this->services->get($service);
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function consume($topic, callable $callback, $configs = [])
 {
     if (!$configs instanceof MapInterface) {
         $configs = new Dictionary($configs);
     }
     if (!$this->configured || $configs->get('force_config')) {
         $configs = $this->setConfig($topic, $configs);
     }
     while (true) {
         $this->fetch($topic, $callback);
     }
 }
예제 #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);
     });
 }
 /**
  * {@inheritDoc}
  * @return $this
  */
 public function groupBy($callback)
 {
     $callback = $this->propertyExtractor($callback);
     $group = new Dictionary();
     foreach ($this as $value) {
         $key = $callback($value);
         if (!$group->containsKey($key)) {
             $element = $this instanceof VectorInterface ? new static([$value]) : new ArrayList([$value]);
             $group->add($key, $element);
         } else {
             $value = $group->get($key)->add($value);
             $group->set($key, $value);
         }
     }
     return $group;
 }
예제 #6
0
 /**
  * {@inheritdoc}
  */
 public function produce($topic, $payload, $configs = [])
 {
     if (!$configs instanceof MapInterface) {
         $configs = new Dictionary($configs);
     }
     if (!$this->configured || $configs->get('force_config')) {
         $configs = $this->setConfig($topic, $configs);
     }
     $partition = $this->choosePartition($topic, isset($configs['partition_strategy']) ? $configs['partition_strategy'] : self::PARTITION_STRATEGY_RANDOM);
     if (is_string($payload)) {
         $payload = [$payload];
     }
     foreach ($payload as $message) {
         $this->connection->setMessages($topic, $partition, $message);
     }
     return $this->connection->send();
 }
예제 #7
0
 /**
  * @expectedException \OutOfBoundsException
  */
 public function testGetInvalidItem()
 {
     $this->coll->set('keyOne', 'testing');
     $this->coll->get('keyTwo');
 }