mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-02 03:37:44 +08:00
Added config-etcd config.
This commit is contained in:
parent
75df18059f
commit
bc371db55a
29
src/config-etcd/publish/etcd.php
Normal file
29
src/config-etcd/publish/etcd.php
Normal 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,
|
||||
];
|
21
src/config-etcd/src/Client.php
Normal file
21
src/config-etcd/src/Client.php
Normal 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.
|
||||
}
|
||||
}
|
17
src/config-etcd/src/ClientFactory.php
Normal file
17
src/config-etcd/src/ClientFactory.php
Normal 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
|
||||
{
|
||||
}
|
21
src/config-etcd/src/ClientInterface.php
Normal file
21
src/config-etcd/src/ClientInterface.php
Normal 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;
|
||||
}
|
@ -18,6 +18,7 @@ class ConfigProvider
|
||||
{
|
||||
return [
|
||||
'dependencies' => [
|
||||
ClientInterface::class => ClientFactory::class,
|
||||
],
|
||||
'commands' => [
|
||||
],
|
||||
|
17
src/config-etcd/src/PipeMessage.php
Normal file
17
src/config-etcd/src/PipeMessage.php
Normal 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
|
||||
{
|
||||
}
|
63
src/config-etcd/src/Process/ConfigFetcherProcess.php
Normal file
63
src/config-etcd/src/Process/ConfigFetcherProcess.php
Normal 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
|
||||
{
|
||||
}
|
||||
}
|
@ -16,4 +16,13 @@ return [
|
||||
'options' => [
|
||||
'timeout' => 10,
|
||||
],
|
||||
|
||||
# Etcd Config Center
|
||||
'enable' => false,
|
||||
'namespaces' => [
|
||||
'application',
|
||||
],
|
||||
'mapping' => [
|
||||
],
|
||||
'interval' => 5,
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user