Merge branch 'master' of github.com:hyperf-cloud/hyperf

This commit is contained in:
李铭昕 2019-06-18 15:55:44 +08:00
commit 5c67767027
4 changed files with 16 additions and 11 deletions

View File

@ -12,6 +12,10 @@ declare(strict_types=1);
namespace Hyperf\JsonRpc;
use Hyperf\JsonRpc\Listener\RegisterProtocolListener;
use Hyperf\JsonRpc\Listener\RegisterServiceListener;
use Hyperf\ServiceGovernance\ServiceManager;
class ConfigProvider
{
public function __invoke(): array
@ -23,6 +27,15 @@ class ConfigProvider
],
'commands' => [
],
'listeners' => [
RegisterProtocolListener::class,
value(function () {
if (class_exists(ServiceManager::class)) {
return RegisterServiceListener::class;
}
return null;
}),
],
'scan' => [
'paths' => [
__DIR__,

View File

@ -12,10 +12,9 @@ declare(strict_types=1);
namespace Hyperf\JsonRpc\Listener;
use Hyperf\Event\Annotation\Listener;
use Hyperf\Event\Contract\ListenerInterface;
use Hyperf\Framework\Event\BeforeServerStart;
use Hyperf\Framework\Event\BeforeWorkerStart;
use Hyperf\Framework\Event\BootApplication;
use Hyperf\JsonRpc\DataFormatter;
use Hyperf\JsonRpc\JsonRpcHttpTransporter;
use Hyperf\JsonRpc\JsonRpcTransporter;
@ -23,9 +22,6 @@ use Hyperf\JsonRpc\PathGenerator;
use Hyperf\Rpc\ProtocolManager;
use Hyperf\Utils\Packer\JsonPacker;
/**
* @Listener
*/
class RegisterProtocolListener implements ListenerInterface
{
/**
@ -41,7 +37,7 @@ class RegisterProtocolListener implements ListenerInterface
public function listen(): array
{
return [
BeforeServerStart::class,
BootApplication::class,
];
}

View File

@ -12,14 +12,10 @@ declare(strict_types=1);
namespace Hyperf\JsonRpc\Listener;
use Hyperf\Event\Annotation\Listener;
use Hyperf\Event\Contract\ListenerInterface;
use Hyperf\RpcServer\Event\AfterPathRegister;
use Hyperf\ServiceGovernance\ServiceManager;
/**
* @Listener
*/
class RegisterServiceListener implements ListenerInterface
{
/**

View File

@ -68,7 +68,7 @@ class ProtocolManager
{
$result = $this->config->get('protocols.' . Str::lower($name) . '.' . Str::lower($target));
if (! is_string($result)) {
throw new InvalidArgumentException(sprintf('Data Formatter %s is not exists.', Str::studly($target, ' ')));
throw new InvalidArgumentException(sprintf('%s is not exists.', Str::studly($target, ' ')));
}
return $result;
}