Added config-etcd config.

This commit is contained in:
李铭昕 2019-07-26 18:35:46 +08:00
parent 75df18059f
commit bc371db55a
8 changed files with 178 additions and 0 deletions

View File

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://doc.hyperf.io
* @contact group@hyperf.io
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
*/
return [
# Etcd Client
'uri' => 'http://127.0.0.1:2379',
'version' => 'v3beta',
'options' => [
'timeout' => 10,
],
# Etcd Config Center
'enable' => false,
'namespaces' => [
'application',
],
'mapping' => [
],
'interval' => 5,
];

View File

@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://doc.hyperf.io
* @contact group@hyperf.io
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
*/
namespace Hyperf\ConfigEtcd;
class Client implements ClientInterface
{
public function pull(): array
{
// TODO: Implement pull() method.
}
}

View File

@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://doc.hyperf.io
* @contact group@hyperf.io
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
*/
namespace Hyperf\ConfigEtcd;
class ClientFactory
{
}

View File

@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://doc.hyperf.io
* @contact group@hyperf.io
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
*/
namespace Hyperf\ConfigEtcd;
interface ClientInterface
{
/**
* Pull the config values from configuration center, and then update the Config values.
*/
public function pull(): array;
}

View File

@ -18,6 +18,7 @@ class ConfigProvider
{ {
return [ return [
'dependencies' => [ 'dependencies' => [
ClientInterface::class => ClientFactory::class,
], ],
'commands' => [ 'commands' => [
], ],

View File

@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://doc.hyperf.io
* @contact group@hyperf.io
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
*/
namespace Hyperf\ConfigEtcd;
class PipeMessage
{
}

View File

@ -0,0 +1,63 @@
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://doc.hyperf.io
* @contact group@hyperf.io
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
*/
namespace Hyperf\ConfigEtcd\Process;
use Hyperf\ConfigEtcd\ClientInterface;
use Hyperf\Contract\ConfigInterface;
use Hyperf\Process\AbstractProcess;
use Hyperf\Process\Annotation\Process;
use Psr\Container\ContainerInterface;
use Swoole\Server;
/**
* @Process(name="apollo-config-fetcher")
*/
class ConfigFetcherProcess extends AbstractProcess
{
/**
* @var Server
*/
private $server;
/**
* @var ClientInterface
*/
private $client;
/**
* @var ConfigInterface
*/
private $config;
public function __construct(ContainerInterface $container)
{
parent::__construct($container);
$this->client = $container->get(ClientInterface::class);
$this->config = $container->get(ConfigInterface::class);
}
public function bind(Server $server): void
{
$this->server = $server;
parent::bind($server);
}
public function isEnable(): bool
{
return $this->config->get('apollo.enable', false);
}
public function handle(): void
{
}
}

View File

@ -16,4 +16,13 @@ return [
'options' => [ 'options' => [
'timeout' => 10, 'timeout' => 10,
], ],
# Etcd Config Center
'enable' => false,
'namespaces' => [
'application',
],
'mapping' => [
],
'interval' => 5,
]; ];