This commit is contained in:
2021-03-23 10:30:14 +08:00
parent c6e8871b9c
commit 14bae86b66
3 changed files with 41 additions and 32 deletions
+21 -15
View File
@@ -4,8 +4,13 @@
namespace Rpc;
use Exception;
use ReflectionException;
use Snowflake\Abstracts\Component;
use Snowflake\Abstracts\Config;
use Snowflake\Exception\ComponentException;
use Snowflake\Exception\ConfigException;
use Snowflake\Exception\NotFindClassException;
use Snowflake\Snowflake;
@@ -19,14 +24,15 @@ class Producer extends Component
private array $producers = [];
/**
* @param $name
* @return Producer|bool
* @throws \ReflectionException
* @throws \Snowflake\Exception\ComponentException
* @throws \Snowflake\Exception\ConfigException
* @throws \Snowflake\Exception\NotFindClassException
*/
/**
* @param $name
* @return Producer|bool
* @throws ReflectionException
* @throws ComponentException
* @throws ConfigException
* @throws NotFindClassException
* @throws Exception
*/
public function get($name): Client|bool
{
if (empty($this->producers)) {
@@ -52,13 +58,13 @@ class Producer extends Component
/**
* @param $name
* @return mixed
* @throws \ReflectionException
* @throws \Snowflake\Exception\ComponentException
* @throws \Snowflake\Exception\ConfigException
* @throws \Snowflake\Exception\NotFindClassException
* @return Client|bool
* @throws ReflectionException
* @throws ComponentException
* @throws ConfigException
* @throws NotFindClassException
*/
public function __get($name): mixed
public function __get($name): Client|bool
{
return $this->get($name); // TODO: Change the autogenerated stub
}
@@ -69,7 +75,7 @@ class Producer extends Component
* @param $rand
* @return string
*/
private function getName($name, $rand)
private function getName($name, $rand): string
{
return 'rpc.client.' . $name . '.' . $rand['host'];
}