Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
simon authored and StyleCIBot committed Jan 15, 2019
1 parent 9a9f95e commit f90ab9c
Show file tree
Hide file tree
Showing 24 changed files with 191 additions and 166 deletions.
22 changes: 11 additions & 11 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,25 @@
'consul' => [
'discover' => [
'driver' => 'http',
'host' => env('SERVICE_DISCOVER_HOST', '127.0.0.1'),
'port' => env('SERVICE_DISCOVER_PORT', 8500),
'uri' => 'agent/services',
'host' => env('SERVICE_DISCOVER_HOST', '127.0.0.1'),
'port' => env('SERVICE_DISCOVER_PORT', 8500),
'uri' => 'agent/services',
],
],

'local' => [
'discover' => [
'path' => env('SERVICE_DISCOVER_PATH', storage_path('micorservice-discover.json'))
'path' => env('SERVICE_DISCOVER_PATH', storage_path('micorservice-discover.json')),
],
],

'swarm' => [
'discover' => [
'driver' => 'http',
'host' => env('SERVICE_DISCOVER_HOST', '127.0.0.1'),
'port' => env('SERVICE_DISCOVER_PORT', 2375),
'host' => env('SERVICE_DISCOVER_HOST', '127.0.0.1'),
'port' => env('SERVICE_DISCOVER_PORT', 2375),
],
]
],
],

/*
Expand Down Expand Up @@ -92,13 +92,13 @@

'clients' => [
'restful' => [
'name' => 'restful',
'driver' => 'http',
'name' => 'restful',
'driver' => 'http',
'options' => [
'timeout' => 1,
//'verify' => resource_path('ssl/cacert.pem'),
],
]
],
],

/*
Expand Down Expand Up @@ -144,5 +144,5 @@

'events' => [

]
],
];
28 changes: 14 additions & 14 deletions src/Clients/Restful.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@

use CrCms\Foundation\Client\ClientManager;
use CrCms\Microservice\Client\Contracts\ClientContract;
use Psr\Http\Message\ResponseInterface;

/**
* Class Restful
* @package CrCms\Microservice\Client\Drivers
* Class Restful.
*/
class Restful implements ClientContract
{
/**
* @var array
*/
protected $headers = [
'User-Agent' => 'CRCMS-Microservice PHP Client',
'User-Agent' => 'CRCMS-Microservice PHP Client',
'Accept-Encoding' => 'gzip,deflate,br',
'Connection' => 'keep-alive',
'Connection' => 'keep-alive',
];

/**
Expand Down Expand Up @@ -60,9 +58,10 @@ class Restful implements ClientContract

/**
* Restful constructor.
*
* @param ClientManager $manager
* @param array $config
* @param array $options
* @param array $config
* @param array $options
*/
public function __construct(ClientManager $manager, array $config, array $options)
{
Expand All @@ -72,18 +71,19 @@ public function __construct(ClientManager $manager, array $config, array $option
}

/**
* @param array $service
* @param string $uri
* @param array $service
* @param string $uri
* @param array|string $params
*
* @return Restful
*/
public function call(array $service, $params = []): ClientContract
{
$this->client->connection([
'name' => $service['name'],
'driver' => $this->config['driver'],
'host' => $service['host'],
'port' => $service['port'],
'name' => $service['name'],
'driver' => $this->config['driver'],
'host' => $service['host'],
'port' => $service['port'],
'settings' => array_merge($this->defaultConfig, $this->config['options'] ?? [], $this->options[$service['name']] ?? []),
])->handle('/', ['headers' => $this->headers, 'method' => $this->method, 'payload' => $params]);

Expand All @@ -110,4 +110,4 @@ public function getContent()
{
return $this->content;
}
}
}
5 changes: 2 additions & 3 deletions src/Concerns/ServiceInstanceConcern.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use CrCms\Microservice\Client\Service;

/**
* Trait ServiceInstanceConcern
* @package CrCms\Microservice\Client\Concerns
* Trait ServiceInstanceConcern.
*/
trait ServiceInstanceConcern
{
Expand All @@ -17,4 +16,4 @@ public function service(): Service
{
return app(Service::class);
}
}
}
13 changes: 7 additions & 6 deletions src/Contracts/CallEventContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,24 @@
use Exception;

/**
* Interface CallEventContract
* @package CrCms\Microservice\Client\Contracts
* Interface CallEventContract.
*/
interface CallEventContract
{
/**
* @param Service $service
* @param array $serverInfo
* @param array $serverInfo
*
* @return void
*/
public function handle(Service $service, array $serverInfo): void;

/**
* @param Service $service
* @param Service $service
* @param Exception $exception
* @param array $serverInfo
* @param array $serverInfo
*
* @return void
*/
public function failed(Service $service, Exception $exception, array $serverInfo): void;
}
}
11 changes: 7 additions & 4 deletions src/Contracts/ClientContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
/**
* @author simon <[email protected]>
* @datetime 2018/6/23 18:36
*
* @link http://crcms.cn/
*
* @copyright Copyright &copy; 2018 Rights Reserved CRCMS
*/

Expand All @@ -12,12 +14,13 @@
interface ClientContract
{
/**
* @param array $service
* @param string $uri
* @param array $service
* @param string $uri
* @param array|string $params
*
* @return ClientContract
*/
public function call(array $service, $params = []): ClientContract;
public function call(array $service, $params = []): self;

/**
* @return int
Expand All @@ -28,4 +31,4 @@ public function getStatusCode(): int;
* @return mixed
*/
public function getContent();
}
}
5 changes: 4 additions & 1 deletion src/Contracts/SelectorContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
/**
* @author simon <[email protected]>
* @datetime 2018/6/25 6:31
*
* @link http://crcms.cn/
*
* @copyright Copyright &copy; 2018 Rights Reserved CRCMS
*/

Expand All @@ -13,7 +15,8 @@ interface SelectorContract
{
/**
* @param string $service
*
* @return array
*/
public function select(string $service): array;
}
}
6 changes: 3 additions & 3 deletions src/Contracts/ServiceDiscoverContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
namespace CrCms\Microservice\Client\Contracts;

/**
* Interface ServiceDiscoverContract
* @package CrCms\Microservice\Client\Contracts
* Interface ServiceDiscoverContract.
*/
interface ServiceDiscoverContract
{
/**
* @param $service
*
* @return array
*/
public function services(string $service): array;
}
}
13 changes: 7 additions & 6 deletions src/Exceptions/ServiceException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
use CrCms\Foundation\ConnectionPool\Exceptions\ConnectionException;
use CrCms\Foundation\ConnectionPool\Exceptions\RequestException;
use CrCms\Microservice\Client\Packer\Packer;
use Exception;
use Illuminate\Http\JsonResponse;
use RuntimeException;
use Exception;
use UnexpectedValueException;

/**
* Class ServiceException
* @package CrCms\Microservice\Client\Exceptions
* Class ServiceException.
*/
class ServiceException extends RuntimeException
{
Expand All @@ -33,6 +31,7 @@ class ServiceException extends RuntimeException

/**
* ServiceException constructor.
*
* @param Exception $exception
*/
public function __construct(Exception $exception)
Expand Down Expand Up @@ -82,6 +81,7 @@ protected function resolveException(Exception $exception)

/**
* @param string $message
*
* @return array
*/
protected function resolveMessage(string $message)
Expand All @@ -90,8 +90,9 @@ protected function resolveMessage(string $message)
}

/**
* @return JsonResponse
* @throws Exception
*
* @return JsonResponse
*/
public function render()
{
Expand All @@ -105,4 +106,4 @@ public function render()
throw $this->exception;
}
}
}
}
5 changes: 2 additions & 3 deletions src/Facades/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace CrCms\Microservice\Client\Facades;

use Illuminate\Support\Facades\Facade;
use CrCms\Microservice\Client\Service as ServiceInstance;
use GuzzleHttp\Promise\Promise;
use Illuminate\Support\Facades\Facade;

/**
* @method static object call(string $service, $uri = '', array $params = [])
Expand All @@ -16,7 +16,6 @@
* @method static ServiceInstance connection(?string $name = null)
*
* Class Service
* @package CrCms\Microservice\Client\Facades
*/
class Service extends Facade
{
Expand All @@ -27,4 +26,4 @@ protected static function getFacadeAccessor(): string
{
return ServiceInstance::class;
}
}
}
Loading

0 comments on commit f90ab9c

Please sign in to comment.