Skip to content

Commit 4fd3f49

Browse files
author
Andrei Popescu
authored
Implements merging of same requests in OlpClient. (#1111)
This commit implements merging of same URL requests for the async OlpClient::CallApi() method by using the previously created PendingUrlRequest(s) classes. The merging is only performed in case the request does not have any body as this could alter the response. Additionaly this commit adds support for HEAD and PATCH requests, already supported by the Network layer. OlpClientTests adapted and extended accordingly with additional test cases. All other tests using mocked networked changed to returning the callback asynchronously. Relates-To: OLPEDGE-1805 Signed-off-by: Andrei Popescu <[email protected]>
1 parent 77931b4 commit 4fd3f49

File tree

5 files changed

+1729
-833
lines changed

5 files changed

+1729
-833
lines changed

olp-cpp-sdk-core/include/olp/core/client/OlpClient.h

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ namespace olp {
3333
namespace client {
3434
/**
3535
* @brief Executes HTTP requests by using the base url and the provided
36-
* parameters and body.
36+
* parameters and body. This class will handle retries based on the
37+
* RetrySettings and will merge all similar URL requests into one.
3738
*/
3839
class CORE_API OlpClient {
3940
public:
@@ -42,6 +43,7 @@ class CORE_API OlpClient {
4243
using RequestBodyType = std::shared_ptr<std::vector<std::uint8_t>>;
4344

4445
OlpClient();
46+
OlpClient(const OlpClientSettings& settings, std::string base_url);
4547
virtual ~OlpClient();
4648

4749
// Movable and copyable
@@ -52,8 +54,10 @@ class CORE_API OlpClient {
5254

5355
/**
5456
* @brief Sets the base URL used for all requests.
55-
56-
* @param base_url The base URL.
57+
*
58+
* @note The base URL can change over time and it is thread safe to change it.
59+
*
60+
* @param base_url The new base URL to be used for all outgoing requests.
5761
*/
5862
void SetBaseUrl(const std::string& base_url);
5963

@@ -67,14 +71,24 @@ class CORE_API OlpClient {
6771
/**
6872
* @brief Gets the default headers that are added to each request.
6973
*
74+
* @note Do not change this while requests are ongoing.
75+
*
7076
* @return The default headers.
7177
*/
7278
ParametersType& GetMutableDefaultHeaders();
7379

7480
/**
7581
* @brief Sets the client settings.
7682
*
83+
* @note Handle with care and do not change while requests are ongoing.
84+
* Ideally the settings would not change during the lifecycle of this
85+
* instance.
86+
*
7787
* @param settings The client settings.
88+
*
89+
* @deprecated This method will be removed by 05.2021. Please use the
90+
* constructor instead. The settings should not change during the lifetime of
91+
* the instance.
7892
*/
7993
void SetSettings(const OlpClientSettings& settings);
8094

0 commit comments

Comments
 (0)