> */ protected array $clients = []; public function __construct(protected Application $app, protected Config $config) { if (! $this->config->getGrpc()['enable']) { throw new InvalidArgumentException('GRPC module is disable, please set `nacos.default.grpc.enable = true`.'); } } public function get(string $namespaceId, Module|string $module = 'config'): GrpcClient { $module instanceof Module && $module = $module->value; if (isset($this->clients[$namespaceId][$module])) { return $this->clients[$namespaceId][$module]; } return $this->clients[$namespaceId][$module] = new GrpcClient($this->app, $this->config, $this->container(), $namespaceId, $module); } /** * @return array> array> */ public function getClients(): array { return $this->clients; } /** * @param string $module config or naming * @return array array */ public function moduleClients(Module|string $module): array { $module instanceof Module && $module = $module->value; $result = []; foreach ($this->clients as $namespaceId => $clients) { foreach ($clients as $key => $client) { if ($key === $module) { $result[$namespaceId] = $client; } } } return $result; } private function container(): ContainerInterface { return ApplicationContext::getContainer(); } }