olp-cpp-sdk 1.24.0
Loading...
Searching...
No Matches
RetrySettings.h
1/*
2 * Copyright (C) 2021-2024 HERE Europe B.V.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * SPDX-License-Identifier: Apache-2.0
17 * License-Filename: LICENSE
18 */
19
20#pragma once
21
22#include <chrono>
23#include <functional>
24
25#include <olp/core/client/BackdownStrategy.h>
26#include <olp/core/client/HttpResponse.h>
27
28namespace olp {
29namespace client {
30
34CORE_API bool DefaultRetryCondition(const olp::client::HttpResponse& response);
35
47struct CORE_API RetrySettings {
52 using BackdownStrategy = std::function<std::chrono::milliseconds(
53 std::chrono::milliseconds, size_t)>;
54
60 using RetryCondition = std::function<bool(const HttpResponse&)>;
61
67 int max_attempts = 3;
68
77 int timeout = 60;
78
79#ifdef OLP_SDK_NETWORK_IOS_BACKGROUND_DOWNLOAD
88 int background_timeout = 600;
89#endif // OLP_SDK_NETWORK_IOS_BACKGROUND_DOWNLOAD
90
99 std::chrono::milliseconds connection_timeout = std::chrono::seconds(30);
100
101#ifdef OLP_SDK_NETWORK_IOS_BACKGROUND_DOWNLOAD
111 std::chrono::milliseconds background_connection_timeout =
112 std::chrono::seconds(600);
113#endif // OLP_SDK_NETWORK_IOS_BACKGROUND_DOWNLOAD
114
123 std::chrono::milliseconds transfer_timeout = std::chrono::seconds(30);
124
129 int initial_backdown_period = 200;
130
137
142};
143
144} // namespace client
145} // namespace olp
This class represents the HTTP response created from the NetworkResponse and the request body.
Definition HttpResponse.h:89
CORE_API bool DefaultRetryCondition(const olp::client::HttpResponse &response)
The default retry condition that disables retries.
Rules all the other namespaces.
Definition AppleSignInProperties.h:24
Computes wait time for the next retry attempt via the exponential backoff with the added jitter.
Definition BackdownStrategy.h:46
A collection of settings that controls how failed requests should be treated by the Data SDK.
Definition RetrySettings.h:47
std::function< std::chrono::milliseconds(std::chrono::milliseconds, size_t)> BackdownStrategy
Calculates the number of retry timeouts based on the initial backdown duration and retries count.
Definition RetrySettings.h:53
std::function< bool(const HttpResponse &)> RetryCondition
Checks whether the retry is desired.
Definition RetrySettings.h:60