public function execute()

in php/src/OpenApiClient.php [1336:1479]


  public function execute($params, $request, $runtime)
  {
    $_runtime = [
      'key' => ''.($runtime->key ? $runtime->key : $this->_key),
      'cert' => ''.($runtime->cert ? $runtime->cert : $this->_cert),
      'ca' => ''.($runtime->ca ? $runtime->ca : $this->_ca),
      'readTimeout' => (($runtime->readTimeout ? $runtime->readTimeout : $this->_readTimeout) + 0),
      'connectTimeout' => (($runtime->connectTimeout ? $runtime->connectTimeout : $this->_connectTimeout) + 0),
      'httpProxy' => ''.($runtime->httpProxy ? $runtime->httpProxy : $this->_httpProxy),
      'httpsProxy' => ''.($runtime->httpsProxy ? $runtime->httpsProxy : $this->_httpsProxy),
      'noProxy' => ''.($runtime->noProxy ? $runtime->noProxy : $this->_noProxy),
      'socks5Proxy' => ''.($runtime->socks5Proxy ? $runtime->socks5Proxy : $this->_socks5Proxy),
      'socks5NetWork' => ''.($runtime->socks5NetWork ? $runtime->socks5NetWork : $this->_socks5NetWork),
      'maxIdleConns' => (($runtime->maxIdleConns ? $runtime->maxIdleConns : $this->_maxIdleConns) + 0),
      'retryOptions' => $this->_retryOptions,
      'ignoreSSL' => $runtime->ignoreSSL,
      'tlsMinVersion' => $this->_tlsMinVersion,
      'disableHttp2' => boolval(($this->_disableHttp2 ? $this->_disableHttp2 : false)),
    ];

    $_retriesAttempted = 0;
    $_lastRequest = null;
    $_lastResponse = null;
    $_context = new RetryPolicyContext([
      'retriesAttempted' => $_retriesAttempted,
    ]);
    while (Dara::shouldRetry($_runtime['retryOptions'], $_context)) {
      if ($_retriesAttempted > 0) {
        $_backoffTime = Dara::getBackoffDelay($_runtime['retryOptions'], $_context);
        if ($_backoffTime > 0) {
          Dara::sleep($_backoffTime);
        }
      }

      $_retriesAttempted++;
      try {
        $_request = new Request();
        // spi = new Gateway();//Gateway implements SPI,这一步在产品 SDK 中实例化
        $headers = $this->getRpcHeaders();
        $globalQueries = [ ];
        $globalHeaders = [ ];
        if (!is_null($this->_globalParameters)) {
          $globalParams = $this->_globalParameters;
          if (!is_null($globalParams->queries)) {
            $globalQueries = $globalParams->queries;
          }

          if (!is_null($globalParams->headers)) {
            $globalHeaders = $globalParams->headers;
          }

        }

        $extendsHeaders = [ ];
        $extendsQueries = [ ];
        if (!is_null($runtime->extendsParameters)) {
          $extendsParameters = $runtime->extendsParameters;
          if (!is_null($extendsParameters->headers)) {
            $extendsHeaders = $extendsParameters->headers;
          }

          if (!is_null($extendsParameters->queries)) {
            $extendsQueries = $extendsParameters->queries;
          }

        }

        $requestContext = new \Darabonba\GatewaySpi\Models\InterceptorContext\request([
          'headers' => Dara::merge([
          ], $globalHeaders, $extendsHeaders, $request->headers, $headers),
          'query' => Dara::merge([
          ], $globalQueries, $extendsQueries, $request->query),
          'body' => $request->body,
          'stream' => $request->stream,
          'hostMap' => $request->hostMap,
          'pathname' => $params->pathname,
          'productId' => $this->_productId,
          'action' => $params->action,
          'version' => $params->version,
          'protocol' => ''.($this->_protocol ? $this->_protocol : $params->protocol),
          'method' => ''.($this->_method ? $this->_method : $params->method),
          'authType' => $params->authType,
          'bodyType' => $params->bodyType,
          'reqBodyType' => $params->reqBodyType,
          'style' => $params->style,
          'credential' => $this->_credential,
          'signatureVersion' => $this->_signatureVersion,
          'signatureAlgorithm' => $this->_signatureAlgorithm,
          'userAgent' => Utils::getUserAgent($this->_userAgent),
        ]);
        $configurationContext = new configuration([
          'regionId' => $this->_regionId,
          'endpoint' => ''.($request->endpointOverride ? $request->endpointOverride : $this->_endpoint),
          'endpointRule' => $this->_endpointRule,
          'endpointMap' => $this->_endpointMap,
          'endpointType' => $this->_endpointType,
          'network' => $this->_network,
          'suffix' => $this->_suffix,
        ]);
        $interceptorContext = new InterceptorContext([
          'request' => $requestContext,
          'configuration' => $configurationContext,
        ]);
        $attributeMap = new AttributeMap([ ]);
        // 1. spi.modifyConfiguration(context: SPI.InterceptorContext, attributeMap: SPI.AttributeMap);
        $this->_spi->modifyConfiguration($interceptorContext, $attributeMap);
        // 2. spi.modifyRequest(context: SPI.InterceptorContext, attributeMap: SPI.AttributeMap);
        $this->_spi->modifyRequest($interceptorContext, $attributeMap);
        $_request->protocol = $interceptorContext->request->protocol;
        $_request->method = $interceptorContext->request->method;
        $_request->pathname = $interceptorContext->request->pathname;
        $_request->query = $interceptorContext->request->query;
        $_request->body = $interceptorContext->request->stream;
        $_request->headers = $interceptorContext->request->headers;
        $_response = Dara::send($_request, $_runtime);
        $_lastRequest = $_request;
        $_lastResponse = $_response;

        $responseContext = new response([
          'statusCode' => $_response->statusCode,
          'headers' => $_response->headers,
          'body' => $_response->body,
        ]);
        $interceptorContext->response = $responseContext;
        // 3. spi.modifyResponse(context: SPI.InterceptorContext, attributeMap: SPI.AttributeMap);
        $this->_spi->modifyResponse($interceptorContext, $attributeMap);
        return [
          'headers' => $interceptorContext->response->headers,
          'statusCode' => $interceptorContext->response->statusCode,
          'body' => $interceptorContext->response->deserializedBody,
        ];
      } catch (DaraException $e) {
        $_context = new RetryPolicyContext([
          'retriesAttempted' => $_retriesAttempted,
          'lastRequest' => $_lastRequest,
          'lastResponse' => $_lastResponse,
          'exception' => $e,
        ]);
        continue;
      }
    }

    throw new DaraUnableRetryException($_context);
  }