mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-11-29 18:27:44 +08:00
Split service-governance
into service-governance
and service-governance-consul
.
This commit is contained in:
parent
14e73c6a7e
commit
efcdf18a93
@ -32,7 +32,7 @@
|
|||||||
- [#3725](https://github.com/hyperf/hyperf/pull/3725) Removed config `config_etcd.php`, please use `config_center.php` instead.
|
- [#3725](https://github.com/hyperf/hyperf/pull/3725) Removed config `config_etcd.php`, please use `config_center.php` instead.
|
||||||
- [#3730](https://github.com/hyperf/hyperf/pull/3730) Removed config `brokers` and `update_brokers` from kafka.
|
- [#3730](https://github.com/hyperf/hyperf/pull/3730) Removed config `brokers` and `update_brokers` from kafka.
|
||||||
- [#3733](https://github.com/hyperf/hyperf/pull/3733) Removed config `zookeeper.php`, please use `config_center.php` instead.
|
- [#3733](https://github.com/hyperf/hyperf/pull/3733) Removed config `zookeeper.php`, please use `config_center.php` instead.
|
||||||
- [#3734](https://github.com/hyperf/hyperf/pull/3734) Splited `nacos` into `config-nacos` and `service-governance-nacos`.
|
- [#3734](https://github.com/hyperf/hyperf/pull/3734) Split `nacos` into `config-nacos` and `service-governance-nacos`.
|
||||||
- [#3772](https://github.com/hyperf/hyperf/pull/3772) Fixed bug that nacos driver do not work.
|
- [#3772](https://github.com/hyperf/hyperf/pull/3772) Fixed bug that nacos driver do not work.
|
||||||
- [#3734](https://github.com/hyperf/hyperf/pull/3734) Renamed `nacos-sdk` as `nacos`.
|
- [#3734](https://github.com/hyperf/hyperf/pull/3734) Renamed `nacos-sdk` as `nacos`.
|
||||||
- [#3737](https://github.com/hyperf/hyperf/pull/3737) Refactor config-center and config driver
|
- [#3737](https://github.com/hyperf/hyperf/pull/3737) Refactor config-center and config driver
|
||||||
|
2
src/service-governance-consul/.gitattributes
vendored
Normal file
2
src/service-governance-consul/.gitattributes
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/tests export-ignore
|
||||||
|
/.github export-ignore
|
25
src/service-governance-consul/.github/workflows/release.yml
vendored
Normal file
25
src/service-governance-consul/.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
on:
|
||||||
|
push:
|
||||||
|
# Sequence of patterns matched against refs/tags
|
||||||
|
tags:
|
||||||
|
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
|
||||||
|
|
||||||
|
name: Release
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
name: Release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Create Release
|
||||||
|
id: create_release
|
||||||
|
uses: actions/create-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ github.ref }}
|
||||||
|
release_name: Release ${{ github.ref }}
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
21
src/service-governance-consul/LICENSE
Normal file
21
src/service-governance-consul/LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) Hyperf
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
45
src/service-governance-consul/composer.json
Normal file
45
src/service-governance-consul/composer.json
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"name": "hyperf/service-governance-consul",
|
||||||
|
"description": "A consul adapter for service governance.",
|
||||||
|
"license": "MIT",
|
||||||
|
"keywords": [
|
||||||
|
"php",
|
||||||
|
"swoole",
|
||||||
|
"hyperf",
|
||||||
|
"service-governance",
|
||||||
|
"consul-adapter"
|
||||||
|
],
|
||||||
|
"homepage": "https://hyperf.io",
|
||||||
|
"support": {
|
||||||
|
"docs": "https://hyperf.wiki",
|
||||||
|
"issues": "https://github.com/hyperf/hyperf/issues",
|
||||||
|
"pull-request": "https://github.com/hyperf/hyperf/pulls",
|
||||||
|
"source": "https://github.com/hyperf/hyperf"
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.3",
|
||||||
|
"hyperf/consul": "~2.2.0",
|
||||||
|
"hyperf/contract": "~2.2.0",
|
||||||
|
"hyperf/service-governance": "~2.2.0",
|
||||||
|
"hyperf/utils": "~2.2.0"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Hyperf\\ServiceGovernanceConsul\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"minimum-stability": "dev",
|
||||||
|
"prefer-stable": true,
|
||||||
|
"config": {
|
||||||
|
"optimize-autoloader": true,
|
||||||
|
"sort-packages": true
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "2.1-dev"
|
||||||
|
},
|
||||||
|
"hyperf": {
|
||||||
|
"config": "Hyperf\\ServiceGovernanceConsul\\ConfigProvider"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
44
src/service-governance-consul/src/ConfigProvider.php
Normal file
44
src/service-governance-consul/src/ConfigProvider.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
/**
|
||||||
|
* This file is part of Hyperf.
|
||||||
|
*
|
||||||
|
* @link https://www.hyperf.io
|
||||||
|
* @document https://hyperf.wiki
|
||||||
|
* @contact group@hyperf.io
|
||||||
|
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||||
|
*/
|
||||||
|
namespace Hyperf\ServiceGovernanceConsul;
|
||||||
|
|
||||||
|
use Hyperf\ServiceGovernanceConsul\Listener\RegisterDriverListener;
|
||||||
|
|
||||||
|
class ConfigProvider
|
||||||
|
{
|
||||||
|
public function __invoke(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'dependencies' => [
|
||||||
|
ConsulAgent::class => ConsulAgentFactory::class,
|
||||||
|
],
|
||||||
|
'listeners' => [
|
||||||
|
RegisterDriverListener::class,
|
||||||
|
],
|
||||||
|
'annotations' => [
|
||||||
|
'scan' => [
|
||||||
|
'paths' => [
|
||||||
|
__DIR__,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'publish' => [
|
||||||
|
[
|
||||||
|
'id' => 'config',
|
||||||
|
'description' => 'The config of service governance.',
|
||||||
|
'source' => __DIR__ . '/../publish/services.php',
|
||||||
|
'destination' => BASE_PATH . '/config/autoload/services.php',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -9,7 +9,7 @@ declare(strict_types=1);
|
|||||||
* @contact group@hyperf.io
|
* @contact group@hyperf.io
|
||||||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
namespace Hyperf\ServiceGovernance\Register;
|
namespace Hyperf\ServiceGovernanceConsul;
|
||||||
|
|
||||||
use Hyperf\Consul\AgentInterface;
|
use Hyperf\Consul\AgentInterface;
|
||||||
|
|
@ -9,7 +9,7 @@ declare(strict_types=1);
|
|||||||
* @contact group@hyperf.io
|
* @contact group@hyperf.io
|
||||||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
namespace Hyperf\ServiceGovernance\Register;
|
namespace Hyperf\ServiceGovernanceConsul;
|
||||||
|
|
||||||
use Hyperf\Consul\Agent;
|
use Hyperf\Consul\Agent;
|
||||||
use Hyperf\Contract\ConfigInterface;
|
use Hyperf\Contract\ConfigInterface;
|
@ -9,7 +9,7 @@ declare(strict_types=1);
|
|||||||
* @contact group@hyperf.io
|
* @contact group@hyperf.io
|
||||||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
namespace Hyperf\ServiceGovernance;
|
namespace Hyperf\ServiceGovernanceConsul;
|
||||||
|
|
||||||
use Hyperf\Consul\AgentInterface;
|
use Hyperf\Consul\AgentInterface;
|
||||||
use Hyperf\Consul\Health;
|
use Hyperf\Consul\Health;
|
||||||
@ -17,8 +17,8 @@ use Hyperf\Consul\HealthInterface;
|
|||||||
use Hyperf\Contract\StdoutLoggerInterface;
|
use Hyperf\Contract\StdoutLoggerInterface;
|
||||||
use Hyperf\Guzzle\ClientFactory;
|
use Hyperf\Guzzle\ClientFactory;
|
||||||
use Hyperf\LoadBalancer\Node;
|
use Hyperf\LoadBalancer\Node;
|
||||||
|
use Hyperf\ServiceGovernance\DriverInterface;
|
||||||
use Hyperf\ServiceGovernance\Exception\ComponentRequiredException;
|
use Hyperf\ServiceGovernance\Exception\ComponentRequiredException;
|
||||||
use Hyperf\ServiceGovernance\Register\ConsulAgent;
|
|
||||||
use Psr\Container\ContainerInterface;
|
use Psr\Container\ContainerInterface;
|
||||||
|
|
||||||
class ConsulDriver implements DriverInterface
|
class ConsulDriver implements DriverInterface
|
@ -9,12 +9,12 @@ declare(strict_types=1);
|
|||||||
* @contact group@hyperf.io
|
* @contact group@hyperf.io
|
||||||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
namespace Hyperf\ServiceGovernance\Listener;
|
namespace Hyperf\ServiceGovernanceConsul\Listener;
|
||||||
|
|
||||||
use Hyperf\Event\Contract\ListenerInterface;
|
use Hyperf\Event\Contract\ListenerInterface;
|
||||||
use Hyperf\Framework\Event\BootApplication;
|
use Hyperf\Framework\Event\BootApplication;
|
||||||
use Hyperf\ServiceGovernance\ConsulDriver;
|
|
||||||
use Hyperf\ServiceGovernance\DriverManager;
|
use Hyperf\ServiceGovernance\DriverManager;
|
||||||
|
use Hyperf\ServiceGovernanceConsul\ConsulDriver;
|
||||||
|
|
||||||
class RegisterDriverListener implements ListenerInterface
|
class RegisterDriverListener implements ListenerInterface
|
||||||
{
|
{
|
@ -11,10 +11,7 @@ declare(strict_types=1);
|
|||||||
*/
|
*/
|
||||||
namespace Hyperf\ServiceGovernance;
|
namespace Hyperf\ServiceGovernance;
|
||||||
|
|
||||||
use Hyperf\ServiceGovernance\Listener\RegisterDriverListener;
|
|
||||||
use Hyperf\ServiceGovernance\Listener\RegisterServiceListener;
|
use Hyperf\ServiceGovernance\Listener\RegisterServiceListener;
|
||||||
use Hyperf\ServiceGovernance\Register\ConsulAgent;
|
|
||||||
use Hyperf\ServiceGovernance\Register\ConsulAgentFactory;
|
|
||||||
|
|
||||||
class ConfigProvider
|
class ConfigProvider
|
||||||
{
|
{
|
||||||
@ -22,11 +19,9 @@ class ConfigProvider
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'dependencies' => [
|
'dependencies' => [
|
||||||
ConsulAgent::class => ConsulAgentFactory::class,
|
|
||||||
IPReaderInterface::class => IPReader::class,
|
IPReaderInterface::class => IPReader::class,
|
||||||
],
|
],
|
||||||
'listeners' => [
|
'listeners' => [
|
||||||
RegisterDriverListener::class,
|
|
||||||
RegisterServiceListener::class,
|
RegisterServiceListener::class,
|
||||||
],
|
],
|
||||||
'annotations' => [
|
'annotations' => [
|
||||||
|
@ -19,17 +19,11 @@ use Hyperf\Framework\Event\MainWorkerStart;
|
|||||||
use Hyperf\Server\Event\MainCoroutineServerStart;
|
use Hyperf\Server\Event\MainCoroutineServerStart;
|
||||||
use Hyperf\ServiceGovernance\DriverManager;
|
use Hyperf\ServiceGovernance\DriverManager;
|
||||||
use Hyperf\ServiceGovernance\IPReaderInterface;
|
use Hyperf\ServiceGovernance\IPReaderInterface;
|
||||||
use Hyperf\ServiceGovernance\Register\ConsulAgent;
|
|
||||||
use Hyperf\ServiceGovernance\ServiceManager;
|
use Hyperf\ServiceGovernance\ServiceManager;
|
||||||
use Psr\Container\ContainerInterface;
|
use Psr\Container\ContainerInterface;
|
||||||
|
|
||||||
class RegisterServiceListener implements ListenerInterface
|
class RegisterServiceListener implements ListenerInterface
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var ConsulAgent
|
|
||||||
*/
|
|
||||||
protected $consulAgent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var StdoutLoggerInterface
|
* @var StdoutLoggerInterface
|
||||||
*/
|
*/
|
||||||
@ -57,7 +51,6 @@ class RegisterServiceListener implements ListenerInterface
|
|||||||
|
|
||||||
public function __construct(ContainerInterface $container)
|
public function __construct(ContainerInterface $container)
|
||||||
{
|
{
|
||||||
$this->consulAgent = $container->get(ConsulAgent::class);
|
|
||||||
$this->logger = $container->get(StdoutLoggerInterface::class);
|
$this->logger = $container->get(StdoutLoggerInterface::class);
|
||||||
$this->serviceManager = $container->get(ServiceManager::class);
|
$this->serviceManager = $container->get(ServiceManager::class);
|
||||||
$this->config = $container->get(ConfigInterface::class);
|
$this->config = $container->get(ConfigInterface::class);
|
||||||
|
@ -17,13 +17,13 @@ use Hyperf\Consul\ConsulResponse;
|
|||||||
use Hyperf\Contract\ConfigInterface;
|
use Hyperf\Contract\ConfigInterface;
|
||||||
use Hyperf\Contract\StdoutLoggerInterface;
|
use Hyperf\Contract\StdoutLoggerInterface;
|
||||||
use Hyperf\Logger\Logger;
|
use Hyperf\Logger\Logger;
|
||||||
use Hyperf\ServiceGovernance\ConsulDriver;
|
|
||||||
use Hyperf\ServiceGovernance\DriverManager;
|
use Hyperf\ServiceGovernance\DriverManager;
|
||||||
use Hyperf\ServiceGovernance\IPReader;
|
use Hyperf\ServiceGovernance\IPReader;
|
||||||
use Hyperf\ServiceGovernance\IPReaderInterface;
|
use Hyperf\ServiceGovernance\IPReaderInterface;
|
||||||
use Hyperf\ServiceGovernance\Listener\RegisterServiceListener;
|
use Hyperf\ServiceGovernance\Listener\RegisterServiceListener;
|
||||||
use Hyperf\ServiceGovernance\Register\ConsulAgent;
|
|
||||||
use Hyperf\ServiceGovernance\ServiceManager;
|
use Hyperf\ServiceGovernance\ServiceManager;
|
||||||
|
use Hyperf\ServiceGovernanceConsul\ConsulAgent;
|
||||||
|
use Hyperf\ServiceGovernanceConsul\ConsulDriver;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
use Monolog\Handler\StreamHandler;
|
use Monolog\Handler\StreamHandler;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
Loading…
Reference in New Issue
Block a user