Skip to content

Commit

Permalink
Few little updates from root go package
Browse files Browse the repository at this point in the history
  • Loading branch information
dcarbone committed Jan 5, 2017
1 parent 97d4088 commit ecb4398
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 14 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"php": ">=5.6.0",
"psr/log": "1.0.*",
"psr/http-message": "1.0.*",
"php-http/client-implementation": "*"
"php-http/client-implementation": "@stable"
},
"autoload": {
"psr-4": {
Expand Down
24 changes: 24 additions & 0 deletions src/Agent/AgentClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,4 +413,28 @@ public function checkFail($checkID, $note = '')

return $err;
}

/**
* @return \DCarbone\PHPConsulAPI\Error|null
*/
public function reload()
{
$r = new Request('put', 'v1/agent/reload', $this->c);

list($_, $_, $err) = $this->requireOK($this->doRequest($r));

return $err;
}

/**
* @return \DCarbone\PHPConsulAPI\Error|null
*/
public function leave()
{
$r = new Request('put', 'v1/agent/leave', $this->c);

list($_, $_, $err) = $this->requireOK($this->doRequest($r));

return $err;
}
}
16 changes: 8 additions & 8 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,19 @@ public static function newDefaultConfigWithClient(HttpClient $client)
]);

$envParams = static::getEnvironmentConfig();
if (isset($envParams['CONSUL_HTTP_ADDR']))
$conf->setAddress($envParams['CONSUL_HTTP_ADDR']);
if (isset($envParams[Consul::HTTPAddrEnvName]))
$conf->setAddress($envParams[Consul::HTTPAddrEnvName]);

if (isset($envParams['CONSUL_HTTP_TOKEN']))
$conf->setToken($envParams['CONSUL_HTTP_TOKEN']);
if (isset($envParams[Consul::HTTPTokenEnvName]))
$conf->setToken($envParams[Consul::HTTPTokenEnvName]);

if (isset($envParams['CONSUL_HTTP_AUTH']))
$conf->setHttpAuth($envParams['CONSUL_HTTP_AUTH']);
if (isset($envParams[Consul::HTTPAuthEnvName]))
$conf->setHttpAuth($envParams[Consul::HTTPAuthEnvName]);

if (isset($envParams['CONSUL_HTTP_SSL']) && $envParams['CONSUL_HTTP_SSL'])
if (isset($envParams[Consul::HTTPSSLEnvName]) && $envParams[Consul::HTTPSSLEnvName])
$conf->setScheme('https');

if (isset($envParams['CONSUL_HTTP_SSL_VERIFY']) && !$envParams['CONSUL_HTTP_SSL_VERIFY'])
if (isset($envParams[Consul::HTTPSSLVerifyEnvName]) && !$envParams[Consul::HTTPSSLVerifyEnvName])
$conf->setInsecureSkipVerify(false);

return $conf;
Expand Down
6 changes: 6 additions & 0 deletions src/Consul.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
*/
class Consul
{
const HTTPAddrEnvName = 'CONSUL_HTTP_ADDR';
const HTTPTokenEnvName = 'CONSUL_HTTP_TOKEN';
const HTTPAuthEnvName = 'CONSUL_HTTP_AUTH';
const HTTPSSLEnvName = 'CONSUL_HTTP_SSL';
const HTTPSSLVerifyEnvName = 'CONSUL_HTTP_SSL_VERIFY';

/** @var KVClient */
public $KV;
/** @var AgentClient */
Expand Down
10 changes: 5 additions & 5 deletions src/PreparedQuery/PreparedQueryClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,20 @@ public function get($queryID, QueryOptions $queryOptions = null)

/**
* @param string $queryID
* @param QueryOptions|null $queryOptions
* @param WriteOptions|null $writeOptions
* @return array(
* @type \DCarbone\PHPConsulAPI\QueryMeta Query meta data
* @type \DCarbone\PHPConsulAPI\WriteMeta Write meta data
* @type \DCarbone\PHPConsulAPI\Error|null error, if any
* )
*/
public function delete($queryID, QueryOptions $queryOptions = null)
public function delete($queryID, WriteOptions $writeOptions = null)
{
$r = new Request('DELETE', sprintf('v1/query/%s', $queryID), $this->c);
$r->setQueryOptions($queryOptions);
$r->setWriteOptions($writeOptions);

/** @var \Psr\Http\Message\ResponseInterface $response */
list($duration, $response, $err) = $this->requireOK($this->doRequest($r));
$qm = $this->buildQueryMeta($duration, $response, $r->getUri());
$qm = $this->buildWriteMeta($duration);

if (null !== $err)
return [null, $qm, $err];
Expand Down

0 comments on commit ecb4398

Please sign in to comment.