Beispiel #1
0
 /**
  * @param QueryOptions|null $queryOptions
  */
 public function setQueryOptions(QueryOptions $queryOptions = null)
 {
     if (null === $queryOptions) {
         return;
     }
     if ('' !== ($dc = $queryOptions->getDatacenter())) {
         $this->params['dc'] = $dc;
     }
     if ($queryOptions->getAllowStale()) {
         $this->params['stale'] = '';
     }
     if ($queryOptions->getRequireConsistent()) {
         $this->params['consistent'] = '';
     }
     if (0 !== ($waitIndex = $queryOptions->getWaitIndex())) {
         $this->params['index'] = $waitIndex;
     }
     if (0 !== ($waitTime = $queryOptions->getWaitTime())) {
         $this->params['wait'] = $waitTime;
     }
     if ('' !== ($token = $queryOptions->getToken())) {
         if ($this->c->isTokenInHeader()) {
             $this->headers['X-Consul-Token'] = $token;
         } else {
             $this->params['token'] = $token;
         }
     }
     if ('' !== ($near = $queryOptions->getNear())) {
         $this->params['near'] = $near;
     }
 }
Beispiel #2
0
 /**
  * Client constructor.
  * @param Config $config
  */
 public function __construct(Config $config = null)
 {
     if (null === $config) {
         $config = Config::newDefaultConfig();
     } else {
         $def = Config::newDefaultConfig();
         if ('' === $config->getAddress()) {
             $config->setAddress($def->getAddress());
         }
         if ('' === $config->getScheme()) {
             $config->setScheme($def->getScheme());
         }
     }
     $this->KV = new KVClient($config);
     $this->Agent = new AgentClient($config);
     $this->Catalog = new CatalogClient($config);
     $this->Status = new StatusClient($config);
     $this->Event = new EventClient($config);
     $this->Health = new HealthClient($config);
     $this->Coordinate = new CoordinateClient($config);
     $this->Session = new SessionClient($config);
     $this->Operator = new OperatorClient($config);
     $this->ACL = new ACLClient($config);
     $this->PreparedQuery = new PreparedQueryClient($config);
 }