リクエストの設定

データ クライアント ベース ライブラリは、複数のレベルの HTTP 要求の設定を調整するために使用できる、非常に詳細な設定をサポートしています。

これらの設定は application.conf 、リソースを使用して定義することも、アプリケーションコードでプログラムによって定義することもできます。 ユーザーが定義した設定がある場合は、ハードコードされた既定の設定が適用されます。この設定は、ほとんどのユースケースで有効です。

さまざまなリソースの設定の使用順序はです

  • ハードコードされた既定の設定は、によって上書きされます
  • で定義された設定 application.conf は、によって上書きされます
  • アプリケーションコードで定義されている設定

設定を定義できる複数のレベル

  1. ベースクライアントレベル

    このレベルの設定は、グローバルに適用されます。つまり、データ クライアント ベース ライブラリでサポートされているすべての API およびエンドポイントに適用されます。

    com.here.platform.data.client.retry-policy.defaults { init-timeout = "10
    millis" request-timeout = "30 seconds" overall-timeout = "10 minutes"
    retry-strategy = "exponential" max-attempts = 5 http-retriable-errors = [408,
    499, 500, 502, 503, 504] }
    

    -- または --

    baseClient = BaseClient().withConfig(ApiConfiguration(...))

  2. API レベル

    このレベルの設定は、特定の API のすべてのエンドポイントにのみ適用されます。

    com.here.platform.data.client.retry-policy.BlobApi.defaults { ... }
    

    -- または --

    blobApi = baseClient.of[BlobApi].withConfig(ApiConfiguration(...))

  3. エンドポイントレベル

    このレベルの設定は、特定のエンドポイントにのみ適用されます。

    com.here.platform.data.client.retry-policy.BlobApi.putBlob { ... }
    

    -- または --

    blobApi.putBlob(...).withConfig(ApiConfiguration(...)).executeToEntity()

特定の設定 ( デバッグなど ) を使用して特定の単一のリクエストインスタンスを実行する必要がある場合は、アプリケーションコードでこれらの設定をプログラムによって定義することによってのみ実行できます。

設定の使用順序は、各レベルで個別に適用されます。 例として、次のユースケースを検討します。

Base Client レベルで設定を持たない場合、ハードコードされたデフォルトが適用されます。 次に 、application.confBlobApi の設定を定義し 、 さらにアプリケーションコードでputBlobエンドポイントに固有の設定を定義します。 putBlob ここで、エンドポイントへのリクエストを実行すると、アプリケーションコードに設定されている特定の設定が適用されます。 BlobApi の他のエンドポイントへのリクエスト を実行する場合 ( 例 getBlob: ) その後、の特定の設定 application.conf が適用されます。 他の API にリクエストを実行すると、デフォルトの設定が適用されます。

リクエストごとの設定エンティティ

現在、この詳細設定の設定は再試行ポリシーにのみ適用されます。 次の表では、再試行ポリシーのパラメータについて説明します。

エンティティ 既定値 意味
initTimeout 10 ミリ秒 再試行の間の最初のタイムアウト
maxRetryTimeout 30 秒 再試行間の最大タイムアウト
取得タイムアウト 10 分 再試行されたすべてのリクエストの全体的なタイムアウト
getableHttpErrors を取得しています [408, 499, 500, 502, 503, 504] 取得可能な HTTP エラーのセット
再試行の戦略 指数関数 再試行間のタイムアウトの方式
maxAttempts 5 最大再試行回数。 0 は無限を意味します

事前定義された再試行戦略

  • exponential: 再試行のタイムアウトが指数関数的に増加し、 2 の累乗 ( 再試行回数 -1) になります。
  • geometric: 再試行のタイムアウトが、係数 2 と再試行回数でリニアに増加します
  • なし : 再試行しません

application.conf を使用した例

HERE トークン
com.here.platform.data.client {
  request {
    defaults {
      retry-policy {
        # initial timeout between retries
        init-timeout = "10 millis"
        # max timeout between retries
        request-timeout = "30 seconds"
        # overall timeout of all retried requests
        overall-timeout = "10 minutes"
        # strategy of increasing timeouts between retries
        retry-strategy = "exponential"
        # max number of retries, 0 is infinite
        max-attempts = 5
        # http retriable errors
        http-retriable-errors = [408, 499, 500, 502, 503, 504]
      }
      # The time after which the blocking request will be failed
      blocking-timeout = "5 minutes"
    }
    # example
    # configApi {
    #   defaults { # <<< This applies for any ConfigApi call if there is no policy defined on any other lower level in ConfigApi
    #     retry-policy {
    #       init-timeout = "10 millis"
    #       request-timeout = "30 seconds"
    #       overall-timeout = "10 minutes"
    #       retry-strategy = "exponential"
    #       max-attempts = 5
    #       http-retriable-errors = [408, 500]
    #     }
    #     blocking-timeout = 1 minutes
    #   }
    #   getCatalogs { # <<< This applies for ConfigApi.getCatalogs call
    #     retry-policy {
    #       overall-timeout = "30 minutes" # <<< all undefined values come from parent, so from ConfigApi-defaults
    #     }
    #     blocking-timeout = 30 seconds
    #   }
    # }
  }
}

」に一致する結果は 件です

    」に一致する結果はありません