diff --git a/Annotation/Rpc/RpcService.php b/Annotation/Rpc/RpcService.php index 778e393c..9b317910 100644 --- a/Annotation/Rpc/RpcService.php +++ b/Annotation/Rpc/RpcService.php @@ -56,6 +56,10 @@ use Snowflake\Snowflake; $rpc = Snowflake::app()->getRpc(); $rpc->addProducer($this->cmd, $handler, $this->config); + if ($handler[0] instanceof IProducer) { + $handler[0]->initClient(); + } + return parent::execute($handler); } diff --git a/Rpc/Producer.php b/Rpc/Producer.php index 0d577489..e08be376 100644 --- a/Rpc/Producer.php +++ b/Rpc/Producer.php @@ -37,10 +37,6 @@ class Producer extends Component $this->consumers[$name] = $handler[0]; $this->producers[$name] = $node; - - if ($handler[0] instanceof IProducer) { - $handler[0]->initClient(); - } }