From 438147dbd88392055a273b9cee5f3214f320275c Mon Sep 17 00:00:00 2001 From: dongwei <838456736@qq.com> Date: Wed, 13 Mar 2019 15:42:45 +0800 Subject: [PATCH] code --- src/Providers/ClientServiceProvider.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Providers/ClientServiceProvider.php b/src/Providers/ClientServiceProvider.php index 158746f..6d59715 100644 --- a/src/Providers/ClientServiceProvider.php +++ b/src/Providers/ClientServiceProvider.php @@ -21,13 +21,14 @@ class ClientServiceProvider extends BaseServiceProvider if (!is_array($config)) { throw new RpcServerException("Application's Rpc Client Config Undefind", 500); } - $this->app->singleton('rpc', function () use ($config) { - return new Client($config); + $client = new Client($config); + $this->app->singleton('rpc', function () use ($client) { + return $client; }); foreach ($config['client'] as $k => $item) { - $this->app->singleton('rpc.' . $k, function () use ($k) { - return app('rpc')->endpoint($k); + $this->app->singleton('rpc.' . $k, function () use ($k, $client) { + return $client->endpoint($k); }); } }