Skip to content

Commit 05d39a4

Browse files
Align cache according to requirements, dataservice write.
If the user do not provide a default cache, SDK will create a default one. Resolves: OLPEDGE-873 Signed-off-by: Mykhailo Kuchma <[email protected]> Signed-off-by: Diachenko Mykahilo <[email protected]>
1 parent bb6508c commit 05d39a4

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
* License-Filename: LICENSE
1818
*/
1919

20-
#include <olp/dataservice/write/StreamLayerClient.h>
20+
#include "olp/dataservice/write/StreamLayerClient.h"
2121

2222
#include <olp/core/cache/DefaultCache.h>
23-
23+
#include <olp/core/client/OlpClientSettingsFactory.h>
2424
#include "StreamLayerClientImpl.h"
2525

2626
namespace olp {
@@ -37,10 +37,12 @@ std::shared_ptr<cache::KeyValueCache> CreateDefaultCache(
3737
StreamLayerClient::StreamLayerClient(client::HRN catalog,
3838
client::OlpClientSettings settings,
3939
FlushSettings flush_settings) {
40-
auto cache = settings.cache;
40+
if (!settings.cache) {
41+
settings.cache = client::OlpClientSettingsFactory::CreateDefaultCache({});
42+
}
43+
4144
impl_ = std::make_shared<StreamLayerClientImpl>(
42-
std::move(catalog), std::move(settings), std::move(cache),
43-
std::move(flush_settings));
45+
std::move(catalog), std::move(settings), std::move(flush_settings));
4446
}
4547

4648
olp::client::CancellableFuture<PublishDataResponse>

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

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

77-
StreamLayerClientImpl::StreamLayerClientImpl(
78-
const HRN& catalog, const OlpClientSettings& settings,
79-
const std::shared_ptr<cache::KeyValueCache>& cache,
80-
const FlushSettings& flush_settings)
81-
: catalog_(catalog),
77+
StreamLayerClientImpl::StreamLayerClientImpl(HRN catalog,
78+
OlpClientSettings settings,
79+
FlushSettings flush_settings)
80+
: catalog_(std::move(catalog)),
8281
catalog_model_(),
83-
settings_(settings),
82+
settings_(std::move(settings)),
8483
apiclient_config_(nullptr),
8584
apiclient_ingest_(nullptr),
8685
apiclient_blob_(nullptr),
8786
apiclient_publish_(nullptr),
8887
init_mutex_(),
8988
init_cv_(),
9089
init_inprogress_(false),
91-
cache_(cache),
90+
cache_(settings_.cache),
9291
cache_mutex_(),
93-
flush_settings_(flush_settings),
92+
flush_settings_(std::move(flush_settings)),
9493
auto_flush_controller_(new AutoFlushController(flush_settings_)) {}
9594

9695
CancellationToken StreamLayerClientImpl::InitApiClients(

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ using InitCatalogModelCallback =
4646
class StreamLayerClientImpl
4747
: public std::enable_shared_from_this<StreamLayerClientImpl> {
4848
public:
49-
StreamLayerClientImpl(const client::HRN& catalog,
50-
const client::OlpClientSettings& settings,
51-
const std::shared_ptr<cache::KeyValueCache>& cache,
52-
const FlushSettings& flush_settings);
49+
StreamLayerClientImpl(client::HRN catalog, client::OlpClientSettings settings,
50+
FlushSettings flush_settings);
5351

5452
olp::client::CancellableFuture<PublishDataResponse> PublishData(
5553
const model::PublishDataRequest& request);

0 commit comments

Comments
 (0)