Skip to content

Commit 6863df6

Browse files
Bohdan Kurylovychborzun
authored andcommitted
Renamed the FlushSettings -> StreamLayerClientSettings
Renamed the FlushSettings into StreamLayerClientSettings. Also, changed the order of parameters in StreamLayerClient. Relates to: OLPEDGE-826 Signed-off-by: Bohdan Kurylovych <[email protected]>
1 parent 437ca0f commit 6863df6

File tree

10 files changed

+39
-27
lines changed

10 files changed

+39
-27
lines changed

examples/dataservice-write/example.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ int RunExample() {
7373
client_settings.authentication_settings = auth_settings;
7474
client_settings.network_request_handler = std::move(http_client);
7575

76+
auto stream_client_settings = StreamLayerClientSettings{};
7677
auto client = std::make_shared<StreamLayerClient>(
77-
olp::client::HRN{kCatalogHRN}, std::move(client_settings));
78+
olp::client::HRN{kCatalogHRN}, std::move(stream_client_settings),
79+
std::move(client_settings));
7880

7981
// Create a publish data request
8082
auto request = PublishDataRequest().WithData(buffer).WithLayerId(kLayer);

olp-cpp-sdk-dataservice-write/include/olp/dataservice/write/StreamLayerClient.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <olp/core/client/ApiResponse.h>
2626
#include <olp/core/client/OlpClientSettings.h>
2727
#include <olp/dataservice/write/DataServiceWriteApi.h>
28-
#include <olp/dataservice/write/FlushSettings.h>
28+
#include <olp/dataservice/write/StreamLayerClientSettings.h>
2929
#include <olp/dataservice/write/generated/model/ResponseOk.h>
3030
#include <olp/dataservice/write/generated/model/ResponseOkSingle.h>
3131
#include <olp/dataservice/write/model/FlushRequest.h>
@@ -72,13 +72,16 @@ class DATASERVICE_WRITE_API StreamLayerClient {
7272
/**
7373
* @brief StreamLayerClient Constructor.
7474
* @param catalog OLP HRN specifying the catalog this client will write to.
75+
* @param client_settings The \c StreamLayerClient settings used to control
76+
* the behaviour of flush mechanism and other StreamLayerClient specific
77+
* properties.
7578
* @param settings Client settings used to control behaviour of this
7679
* StreamLayerClient instance.
77-
* @param flush_settings Optional defines settings that effect cached
7880
* partitions to be flushed. is provided a default in-memory cache is used.
7981
*/
80-
StreamLayerClient(client::HRN catalog, client::OlpClientSettings settings,
81-
FlushSettings flush_settings = FlushSettings());
82+
StreamLayerClient(client::HRN catalog,
83+
StreamLayerClientSettings client_settings,
84+
client::OlpClientSettings settings);
8285

8386
/**
8487
* @brief Call to publish data into an OLP Stream Layer.

olp-cpp-sdk-dataservice-write/include/olp/dataservice/write/FlushSettings.h renamed to olp-cpp-sdk-dataservice-write/include/olp/dataservice/write/StreamLayerClientSettings.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ namespace olp {
2929
namespace dataservice {
3030
namespace write {
3131

32-
struct DATASERVICE_WRITE_API FlushSettings {
32+
/**
33+
* @brief StreamLayerClientSettings settings class for \c StreamLayerClient. Use
34+
* this class to configure the behaviour of \c StreamLayerClient specific logic.
35+
*/
36+
struct DATASERVICE_WRITE_API StreamLayerClientSettings {
3337
/**
3438
@brief The maximum number of requests that can be stored
3539
boost::none to store all requests. Must be positive.

olp-cpp-sdk-dataservice-write/src/StreamLayerClient.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ std::shared_ptr<cache::KeyValueCache> CreateDefaultCache(
3535
}
3636

3737
StreamLayerClient::StreamLayerClient(client::HRN catalog,
38-
client::OlpClientSettings settings,
39-
FlushSettings flush_settings) {
38+
StreamLayerClientSettings client_settings,
39+
client::OlpClientSettings settings) {
4040
if (!settings.cache) {
4141
settings.cache = client::OlpClientSettingsFactory::CreateDefaultCache({});
4242
}
4343

4444
impl_ = std::make_shared<StreamLayerClientImpl>(
45-
std::move(catalog), std::move(settings), std::move(flush_settings));
45+
std::move(catalog), std::move(client_settings), std::move(settings));
4646
}
4747

4848
olp::client::CancellableFuture<PublishDataResponse>

olp-cpp-sdk-dataservice-write/src/StreamLayerClientImpl.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ void ExecuteOrSchedule(const OlpClientSettings& settings,
7474
}
7575
} // namespace
7676

77-
StreamLayerClientImpl::StreamLayerClientImpl(HRN catalog,
78-
OlpClientSettings settings,
79-
FlushSettings flush_settings)
77+
StreamLayerClientImpl::StreamLayerClientImpl(
78+
HRN catalog, StreamLayerClientSettings client_settings,
79+
OlpClientSettings settings)
8080
: catalog_(std::move(catalog)),
8181
catalog_model_(),
8282
settings_(std::move(settings)),
@@ -89,7 +89,7 @@ StreamLayerClientImpl::StreamLayerClientImpl(HRN catalog,
8989
init_inprogress_(false),
9090
cache_(settings_.cache),
9191
cache_mutex_(),
92-
flush_settings_(std::move(flush_settings)),
92+
stream_client_settings_(std::move(client_settings)),
9393
auto_flush_controller_(new AutoFlushController(AutoFlushSettings{})) {}
9494

9595
CancellationToken StreamLayerClientImpl::InitApiClients(
@@ -286,9 +286,9 @@ boost::optional<std::string> StreamLayerClientImpl::Queue(
286286
"PublishDataRequest does not contain a Layer ID");
287287
}
288288

289-
if (flush_settings_.maximum_requests) {
289+
if (stream_client_settings_.maximum_requests) {
290290
if (!(StreamLayerClientImpl::QueueSize() <
291-
*flush_settings_.maximum_requests)) {
291+
*stream_client_settings_.maximum_requests)) {
292292
return boost::make_optional<std::string>(
293293
"Maximum number of requests has reached");
294294
}

olp-cpp-sdk-dataservice-write/src/StreamLayerClientImpl.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ using InitCatalogModelCallback =
4646
class StreamLayerClientImpl
4747
: public std::enable_shared_from_this<StreamLayerClientImpl> {
4848
public:
49-
StreamLayerClientImpl(client::HRN catalog, client::OlpClientSettings settings,
50-
FlushSettings flush_settings);
49+
StreamLayerClientImpl(client::HRN catalog,
50+
StreamLayerClientSettings client_settings,
51+
client::OlpClientSettings settings);
5152

5253
olp::client::CancellableFuture<PublishDataResponse> PublishData(
5354
const model::PublishDataRequest& request);
@@ -112,7 +113,7 @@ class StreamLayerClientImpl
112113

113114
std::shared_ptr<cache::KeyValueCache> cache_;
114115
mutable std::mutex cache_mutex_;
115-
FlushSettings flush_settings_;
116+
StreamLayerClientSettings stream_client_settings_;
116117
std::unique_ptr<AutoFlushController> auto_flush_controller_;
117118
};
118119

tests/functional/olp-cpp-sdk-dataservice-write/DataserviceWriteStreamLayerClientCacheTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class DataserviceWriteStreamLayerClientCacheTest : public ::testing::Test {
155155
settings.cache = disk_cache_;
156156

157157
return std::make_shared<StreamLayerClient>(
158-
olp::client::HRN{GetTestCatalog()}, settings, flush_settings_);
158+
olp::client::HRN{GetTestCatalog()}, stream_client_settings_, settings);
159159
}
160160

161161
private:
@@ -177,7 +177,7 @@ class DataserviceWriteStreamLayerClientCacheTest : public ::testing::Test {
177177
std::shared_ptr<std::vector<unsigned char>> data_;
178178

179179
std::shared_ptr<olp::cache::DefaultCache> disk_cache_;
180-
FlushSettings flush_settings_;
180+
StreamLayerClientSettings stream_client_settings_;
181181
};
182182

183183
// Static network instance is necessary as it needs to outlive any created

tests/functional/olp-cpp-sdk-dataservice-write/DataserviceWriteStreamLayerClientTest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ class DataserviceWriteStreamLayerClientTest : public ::testing::Test {
184184
olp::client::OlpClientSettingsFactory::CreateDefaultTaskScheduler(1u);
185185

186186
return std::make_shared<StreamLayerClient>(
187-
olp::client::HRN{GetTestCatalog()}, settings);
187+
olp::client::HRN{GetTestCatalog()}, StreamLayerClientSettings{},
188+
settings);
188189
}
189190

190191
private:

tests/integration/olp-cpp-sdk-dataservice-write/StreamLayerClientCacheTest.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class StreamLayerClientCacheTest : public ::testing::Test {
134134
SetUpCommonNetworkMockCalls(*network_);
135135

136136
return std::make_shared<StreamLayerClient>(
137-
olp::client::HRN{GetTestCatalog()}, client_settings, flush_settings_);
137+
olp::client::HRN{GetTestCatalog()}, stream_client_settings_, client_settings);
138138
}
139139

140140
void SetUpCommonNetworkMockCalls(NetworkMock& network) {
@@ -282,7 +282,7 @@ class StreamLayerClientCacheTest : public ::testing::Test {
282282

283283
protected:
284284
std::shared_ptr<olp::cache::DefaultCache> disk_cache_;
285-
FlushSettings flush_settings_;
285+
StreamLayerClientSettings stream_client_settings_;
286286
std::shared_ptr<NetworkMock> network_;
287287
std::shared_ptr<StreamLayerClient> client_;
288288
std::shared_ptr<std::vector<unsigned char>> data_;
@@ -438,7 +438,7 @@ TEST_F(StreamLayerClientCacheTest, FlushDataMaxEventsInvalidCustomSetting) {
438438

439439
TEST_F(StreamLayerClientCacheTest, FlushSettingsMaximumRequests) {
440440
disk_cache_->Close();
441-
ASSERT_EQ(flush_settings_.maximum_requests, boost::none);
441+
ASSERT_EQ(stream_client_settings_.maximum_requests, boost::none);
442442
client_ = CreateStreamLayerClient();
443443
{
444444
testing::InSequence dummy;
@@ -460,14 +460,14 @@ TEST_F(StreamLayerClientCacheTest, FlushSettingsMaximumRequests) {
460460
for (auto& single_response : response) {
461461
ASSERT_NO_FATAL_FAILURE(PublishDataSuccessAssertions(single_response));
462462
}
463-
flush_settings_.maximum_requests = 10;
463+
stream_client_settings_.maximum_requests = 10;
464464
client_ = CreateStreamLayerClient();
465465
ASSERT_NO_FATAL_FAILURE(MaximumRequestsSuccessAssertions(10));
466466
client_ = CreateStreamLayerClient();
467467
ASSERT_NO_FATAL_FAILURE(MaximumRequestsSuccessAssertions(10, 13));
468468
client_ = CreateStreamLayerClient();
469469
ASSERT_NO_FATAL_FAILURE(MaximumRequestsSuccessAssertions(10, 9));
470-
flush_settings_.maximum_requests = 0;
470+
stream_client_settings_.maximum_requests = 0;
471471
client_ = CreateStreamLayerClient();
472472
ASSERT_NO_FATAL_FAILURE(MaximumRequestsSuccessAssertions(0, 10));
473473
}

tests/integration/olp-cpp-sdk-dataservice-write/StreamLayerClientTest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ class StreamLayerClientTest : public ::testing::Test {
149149
SetUpCommonNetworkMockCalls(*network_);
150150

151151
return std::make_shared<StreamLayerClient>(
152-
olp::client::HRN{GetTestCatalog()}, client_settings);
152+
olp::client::HRN{GetTestCatalog()}, StreamLayerClientSettings{},
153+
client_settings);
153154
}
154155

155156
void SetUpCommonNetworkMockCalls(NetworkMock& network) {

0 commit comments

Comments
 (0)