Do call service

@param string $func
@param array  $params

@throws \Throwable
@return mixed
334394
public function call(string $func, array $params)
    {
        $profileKey = $this->interface . '->' . $func;
        $fallback = $this->getFallbackHandler($func);
        $closeStatus = true;

        try {
            $connectPool    = $this->getPool();
            $circuitBreaker = $this->getBreaker();

            /* @var $client AbstractServiceConnection */
            $client = $connectPool->getConnection();

            $packer   = service_packer();
            $type     = $this->getPackerName();
            $data     = $packer->formatData($this->interface, $this->version, $func, $params);
            $packData = $packer->pack($data, $type);

            $result = $circuitBreaker->call([$client, 'send'], [$packData], $fallback);
            if ($result === null || $result === false) {
                return null;
            }

            App::profileStart($profileKey);
            try {
                $result = $client->receive();
            } catch (\Throwable $ex) {
                // Client is not connected to server
                if ($ex instanceof RpcClientException && in_array($ex->getCode(), [0, 5001, 104])) {
                    // 0    Send failed, recv data is empty
                    // 104  Connection reset by peer
                    // 5001 SW_ERROR_CLIENT_NO_CONNECTION
                    App::warning(sprintf('%s call %s retried, data=%s, message=%s, code=%s',
                        $this->interface,
                        $func,
                        json_encode($data, JSON_UNESCAPED_UNICODE),
                        $ex->getMessage(),
                        $ex->getCode()
                    ));
                    $client->reconnect();
                    $circuitBreaker->call([$client, 'send'], [$packData], $fallback);
                    $result = $client->receive();
                } else {
                    throw $ex;
                }
            }

            App::profileEnd($profileKey);
            App::debug(sprintf('%s call %s success, data=%s', $this->interface, $func, json_encode($data, JSON_UNESCAPED_UNICODE)));

            $result = $packer->unpack($result);
            $data = $packer->checkData($result);
            $closeStatus = false;
        } catch (\Throwable $throwable) {
            // If the client is normal, no need to close it.
            if ($closeStatus && isset($client) && $client instanceof AbstractServiceConnection) {
                $client->close();
                App::error(sprintf('%s call %s failed, data=%s, message=%s, code=%s',
                    $this->interface,
                    $func,
                    json_encode($data, JSON_UNESCAPED_UNICODE),
                    $throwable->getMessage(),
                    $throwable->getCode()
                ));
            }

            if (empty($fallback)) {
                throw $throwable;
            }
            $data = PhpHelper::call($fallback, $params);
        } finally {
            if (isset($client) && $client instanceof AbstractServiceConnection) {
                $client->release(true);
            }
        }

        return $data;
    }
266209
public function run(callable $callback, ...$params)
    {
        $item = array_shift($this->instances);
        if (empty($item)) {
            return call_user_func_array($callback, $params);
        }
        return $item->handle($callback, function () use ($callback, $params) {
            return $this->run($callback, ...$params);
        });
    }
851105
public function callback($callback, $func, $args=array())
	{
		// Make sure the callback is set (this is protecting us when running in non-interactive mode and callbacks aren't set)
		if (!isset($this->callbacks[$callback]))
		{
			return false;
		}

		// Call function
		return call_user_func_array(array($this->callbacks[$callback], $func), $args);
	}
174439
public static function jsonResponse(callable $fun): callable{
        return function (Request $request, Response $response, array $args) use ($fun){
            return $response->withJson($fun($request, $response, $args));
        };
    }
1304128
protected function call($method, array $params = array())
    {
        $this->init();

        // Prepare headers
        $this->soapClient->__setSoapHeaders($this->getSessionHeader());

        $requestEvent = new Event\RequestEvent($method, $params);
        $this->dispatch(Events::REQUEST, $requestEvent);

        try {
            $result = $this->soapClient->$method($params);
        } catch (\SoapFault $soapFault) {
            $faultEvent = new Event\FaultEvent($soapFault, $requestEvent);
            $this->dispatch(Events::FAULT, $faultEvent);

            throw $soapFault;
        }

        // No result e.g. for logout, delete with empty array
        if (!isset($result->result)) {
            return array();
        }

        $this->dispatch(
            Events::RESPONSE,
            new Event\ResponseEvent($requestEvent, $result->result)
        );

        return $result->result;
    }
266001
public function call(...$params)
    {
        $params = $params ?: $this->params;
        if(!$this->instanciated) {
            $this->instanciate();
        }

        return call_user_func_array($this->callable, $params);
    }
380622
public static Response call(String server, String service, String... params) {
        return call(server, service, false, params);
    }
843267
protected function request($method, $params)
    {
        Log::debug('RpcClient call', ['method'=>$method, 'params'=>$params, 'config'=>$this->config]);

        return call_user_func_array(
                [$this->connection(), 'execute'],
                [$method,$params]
            );
    }
928828
function grab($func,$args=NULL) {
		if (preg_match('/(.+)\h*(->|::)\h*(.+)/s',$func,$parts)) {
			// Convert string to executable PHP callback
			if (!class_exists($parts[1]))
				user_error(sprintf(self::E_Class,$parts[1]),E_USER_ERROR);
			if ($parts[2]=='->') {
				if (is_subclass_of($parts[1],'Prefab'))
					$parts[1]=call_user_func($parts[1].'::instance');
				elseif ($container=$this->get('CONTAINER')) {
					if (is_object($container) && is_callable([$container,'has'])
						&& $container->has($parts[1])) // PSR11
						$parts[1]=call_user_func([$container,'get'],$parts[1]);
					elseif (is_callable($container))
						$parts[1]=call_user_func($container,$parts[1],$args);
					elseif (is_string($container) &&
						is_subclass_of($container,'Prefab'))
						$parts[1]=call_user_func($container.'::instance')->
							get($parts[1]);
					else
						user_error(sprintf(self::E_Class,
							$this->stringify($parts[1])),
							E_USER_ERROR);
				}
				else {
					$ref=new ReflectionClass($parts[1]);
					$parts[1]=method_exists($parts[1],'__construct') && $args?
						$ref->newinstanceargs($args):
						$ref->newinstance();
				}
			}
			$func=[$parts[1],$parts[3]];
		}
		return $func;
	}
267058
public function callback($func) {
        if (!$this->_isValid) {
            return $this;
        }
        $this->_isValid = (bool) $func($this->_unsafeVar);
        return $this;
    }
331861
public function call(callable $callable, ...$params)
    {
        foreach ($this->settings as $key => $value) {
            $this->ini->set($key, $value);
        }

        $result = null;
        $exception = null;
        try {
            $result = $callable(...$params);
        } catch (\Throwable $e) {
            $exception = $e;
        }

        $this->ini->cleanup();

        if ($exception) {
            throw $exception;
        }

        return $result;
    }
1090993
public function allowPhpFunction($func)
	{
		if (is_array($func))
			foreach ($func as $fname)
				$this->allowedPhpFunctions[strtolower($fname)] = true;
		else
			$this->allowedPhpFunctions[strtolower($func)] = true;
	}
396342
protected function call_handler($name, array $params = array())
    {
        if(array_key_exists($name,$this->call_handlers)) {
            go(function () use ($name, $params) {
                sd_call_user_func_array($this->call_handlers[$name], $params);
            });
        }
    }
252961
public function call($name, array $params = [])
    {
        $this->checkName($name);

        array_unshift($params, $this);
        call_user_func_array($this->callbacks[$name], $params);

        return $this;
    }
311420
public static function call($message, callable $func)
    {
        $time = microtime(true);

        static::output($message . " [START]");

        static::$indent++;

        $func();

        static::$indent--;

        static::output($message . " [END] (" . number_format(microtime(true) - $time, 3) . ")");
    }
1319827
protected function invoke($controller, $method, $params)
    {
        if (!class_exists($controller)) {
            throw new Exception("Controller [ $controller ] does not exist.");
        }

        try {
            $instance = $this->container->make($controller);

            $resolving = $this->container->resolveMethod($controller, $method, $params, true);

            $this->validateForm($resolving);

            return call_user_func_array([$instance, $method], $resolving);
        } catch (DefinitionException $e) {
            throw new BindingException("Binding Error [ ". $e->getMessage() ." ]");
        }

    }
717564
public function on($key,$func,$priority=10,$options=array()) {
		$call = $options ? array($func,$options) : $func;
		if ($e = &$this->f3->ref($this->ekey.$key))
			$e[$priority][] = $call;
		else
			$e = array($priority=>array($call));
		krsort($e);
	}