Add an abstraction PipeMessage class and uniform the PipeMessage class of all drivers

This commit is contained in:
huangzhhui 2021-06-25 00:23:35 +08:00 committed by 李铭昕
parent 02d514427e
commit 8d1ab1fad5
11 changed files with 6 additions and 152 deletions

View File

@ -16,8 +16,6 @@ use Psr\Container\ContainerInterface;
class AliyunAcmDriver extends AbstractDriver
{
protected $pipeMessage = PipeMessage::class;
protected $driverName = 'aliyun_acm';
public function __construct(ContainerInterface $container)

View File

@ -1,32 +0,0 @@
<?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\ConfigAliyunAcm;
use Hyperf\ConfigCenter\Contract\PipeMessageInterface;
class PipeMessage implements PipeMessageInterface
{
/**
* @var array
*/
public $data;
public function __construct($data)
{
$this->data = $data;
}
public function getData(): array
{
return $this->data;
}
}

View File

@ -23,8 +23,6 @@ class ApolloDriver extends AbstractDriver
protected $driverName = 'apollo';
protected $pipeMessage = PipeMessage::class;
public function __construct(ContainerInterface $container)
{
parent::__construct($container);

View File

@ -1,32 +0,0 @@
<?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\ConfigApollo;
use Hyperf\ConfigCenter\Contract\PipeMessageInterface;
class PipeMessage implements PipeMessageInterface
{
/**
* @var array
*/
public $data;
public function __construct($data)
{
$this->data = $data;
}
public function getData(): array
{
return $this->data ?? [];
}
}

View File

@ -54,7 +54,7 @@ abstract class AbstractDriver implements DriverInterface
/**
* @var null|string
*/
protected $pipeMessage;
protected $pipeMessage = PipeMessage::class;
/**
* @var string

View File

@ -1,24 +1,17 @@
<?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\ConfigEtcd;
namespace Hyperf\ConfigCenter;
use Hyperf\ConfigCenter\Contract\PipeMessageInterface;
class PipeMessage implements PipeMessageInterface
{
/**
* @var array
*/
public $data;
protected $data = [];
public function __construct(array $data)
{
@ -29,4 +22,4 @@ class PipeMessage implements PipeMessageInterface
{
return $this->data;
}
}
}

View File

@ -29,8 +29,6 @@ class EtcdDriver extends AbstractDriver
protected $driverName = 'etcd';
protected $pipeMessage = PipeMessage::class;
public function __construct(ContainerInterface $container)
{
parent::__construct($container);

View File

@ -12,7 +12,6 @@ declare(strict_types=1);
namespace Hyperf\ConfigNacos;
use Hyperf\ConfigCenter\AbstractDriver;
use Hyperf\ConfigNacos\PipeMessage;
use Hyperf\Utils\Arr;
use Psr\Container\ContainerInterface;
@ -25,8 +24,6 @@ class NacosDriver extends AbstractDriver
protected $driverName = 'nacos';
protected $pipeMessage = PipeMessage::class;
public function __construct(ContainerInterface $container)
{
parent::__construct($container);

View File

@ -1,32 +0,0 @@
<?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\ConfigNacos;
use Hyperf\ConfigCenter\Contract\PipeMessageInterface;
class PipeMessage implements PipeMessageInterface
{
/**
* @var array
*/
public $data;
public function __construct(array $data)
{
$this->data = $data;
}
public function getData(): array
{
return $this->data;
}
}

View File

@ -1,32 +0,0 @@
<?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\ConfigZookeeper;
use Hyperf\ConfigCenter\Contract\PipeMessageInterface;
class PipeMessage implements PipeMessageInterface
{
/**
* @var array
*/
public $data;
public function __construct($data)
{
$this->data = $data;
}
public function getData(): array
{
return $this->data ?? [];
}
}

View File

@ -16,8 +16,6 @@ use Psr\Container\ContainerInterface;
class ZookeeperDriver extends AbstractDriver
{
protected $pipeMessage = PipeMessage::class;
protected $driverName = 'zookeeper';
public function __construct(ContainerInterface $container)