From bc371db55af4e16cd527102b78c628d783e392a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=93=AD=E6=98=95?= <715557344@qq.com> Date: Fri, 26 Jul 2019 18:35:46 +0800 Subject: [PATCH] Added config-etcd config. --- src/config-etcd/publish/etcd.php | 29 +++++++++ src/config-etcd/src/Client.php | 21 +++++++ src/config-etcd/src/ClientFactory.php | 17 +++++ src/config-etcd/src/ClientInterface.php | 21 +++++++ src/config-etcd/src/ConfigProvider.php | 1 + src/config-etcd/src/PipeMessage.php | 17 +++++ .../src/Process/ConfigFetcherProcess.php | 63 +++++++++++++++++++ src/etcd/publish/etcd.php | 9 +++ 8 files changed, 178 insertions(+) create mode 100644 src/config-etcd/publish/etcd.php create mode 100644 src/config-etcd/src/Client.php create mode 100644 src/config-etcd/src/ClientFactory.php create mode 100644 src/config-etcd/src/ClientInterface.php create mode 100644 src/config-etcd/src/PipeMessage.php create mode 100644 src/config-etcd/src/Process/ConfigFetcherProcess.php diff --git a/src/config-etcd/publish/etcd.php b/src/config-etcd/publish/etcd.php new file mode 100644 index 000000000..4d8fb969c --- /dev/null +++ b/src/config-etcd/publish/etcd.php @@ -0,0 +1,29 @@ + 'http://127.0.0.1:2379', + 'version' => 'v3beta', + 'options' => [ + 'timeout' => 10, + ], + + # Etcd Config Center + 'enable' => false, + 'namespaces' => [ + 'application', + ], + 'mapping' => [ + ], + 'interval' => 5, +]; diff --git a/src/config-etcd/src/Client.php b/src/config-etcd/src/Client.php new file mode 100644 index 000000000..1cb0e82c4 --- /dev/null +++ b/src/config-etcd/src/Client.php @@ -0,0 +1,21 @@ + [ + ClientInterface::class => ClientFactory::class, ], 'commands' => [ ], diff --git a/src/config-etcd/src/PipeMessage.php b/src/config-etcd/src/PipeMessage.php new file mode 100644 index 000000000..58e5d1a5e --- /dev/null +++ b/src/config-etcd/src/PipeMessage.php @@ -0,0 +1,17 @@ +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 + { + } +} diff --git a/src/etcd/publish/etcd.php b/src/etcd/publish/etcd.php index 7532af792..4d0cb99a9 100644 --- a/src/etcd/publish/etcd.php +++ b/src/etcd/publish/etcd.php @@ -16,4 +16,13 @@ return [ 'options' => [ 'timeout' => 10, ], + + # Etcd Config Center + 'enable' => false, + 'namespaces' => [ + 'application', + ], + 'mapping' => [ + ], + 'interval' => 5, ];