olp-cpp-sdk  1.18.1
Static Public Member Functions | List of all members
olp::client::OlpClientSettingsFactory Class Referencefinal

Fills in the OlpClientSettings structure with default handlers. More...

#include <OlpClientSettingsFactory.h>

Static Public Member Functions

static std::unique_ptr< thread::TaskSchedulerCreateDefaultTaskScheduler (size_t thread_count=1u)
 Creates the TaskScheduler instance used for all the delayed operations. More...
 
static std::shared_ptr< http::NetworkCreateDefaultNetworkRequestHandler (size_t max_requests_count=30u)
 Creates the Network instance used for all the non-local requests. More...
 
static std::shared_ptr< http::NetworkCreateDefaultNetworkRequestHandler (http::NetworkInitializationSettings settings)
 Creates the Network instance used for all the non-local requests. More...
 
static std::unique_ptr< cache::KeyValueCacheCreateDefaultCache (cache::CacheSettings settings)
 Creates the KeyValueCache instance that includes both a small memory LRU cache and a larger persistent database cache. More...
 
static void PrewarmConnection (const OlpClientSettings &settings, const std::string &url, http::Network::Callback callback=nullptr)
 This function helps you prewarm the connection to the provided host. More...
 

Detailed Description

Fills in the OlpClientSettings structure with default handlers.

Member Function Documentation

◆ CreateDefaultCache()

static std::unique_ptr<cache::KeyValueCache> olp::client::OlpClientSettingsFactory::CreateDefaultCache ( cache::CacheSettings  settings)
static

Creates the KeyValueCache instance that includes both a small memory LRU cache and a larger persistent database cache.

The returned cache instance is initialized, opened, and ready to be used.

Note
The database cache is only created if the provided CacheSettings instance includes a valid disk path with the corresponding write permissions set.
Parameters
[in]settingsThe CacheSettings instance.
Returns
The KeyValueCache instance.

◆ CreateDefaultNetworkRequestHandler() [1/2]

static std::shared_ptr<http::Network> olp::client::OlpClientSettingsFactory::CreateDefaultNetworkRequestHandler ( http::NetworkInitializationSettings  settings)
static

Creates the Network instance used for all the non-local requests.

Defaulted to platform-specific implementation.

On UNIX platforms, the default network request handler is libcurl-based and has the known issue of static initialization and cleanup that needs special care. Therefore, we recommend initializing this network request handler at a very early stage, preferably as global static or from the main thread, and pass it on to every created client. For this matter, it is also not recommended to create multiple network request handlers.

See also
cURL documentation for more information.
Parameters
[in]settingsThe NetworkInitializationSettings instance.
Returns
The Network instance.

◆ CreateDefaultNetworkRequestHandler() [2/2]

static std::shared_ptr<http::Network> olp::client::OlpClientSettingsFactory::CreateDefaultNetworkRequestHandler ( size_t  max_requests_count = 30u)
static

Creates the Network instance used for all the non-local requests.

Defaulted to platform-specific implementation.

On UNIX platforms, the default network request handler is libcurl-based and has the known issue of static initialization and cleanup that needs special care. Therefore, we recommend initializing this network request handler at a very early stage, preferably as global static or from the main thread, and pass it on to every created client. For this matter, it is also not recommended to create multiple network request handlers.

See also
cURL documentation for more information.
Returns
The Network instance.

◆ CreateDefaultTaskScheduler()

static std::unique_ptr<thread::TaskScheduler> olp::client::OlpClientSettingsFactory::CreateDefaultTaskScheduler ( size_t  thread_count = 1u)
static

Creates the TaskScheduler instance used for all the delayed operations.

Defaulted to olp::thread::ThreadPoolTaskScheduler with one worker thread spawned by default.

Returns
The TaskScheduler instance.

◆ PrewarmConnection()

static void olp::client::OlpClientSettingsFactory::PrewarmConnection ( const OlpClientSettings settings,
const std::string &  url,
http::Network::Callback  callback = nullptr 
)
static

This function helps you prewarm the connection to the provided host.

Prewarming includes DNS prefetch and TLS preconnect issued with the OPTIONS http call without any data up or download and is performed asynchronously.

Note
This only makes sense on platforms which actually keep TCP sockets and connections alive for some time and only if you have max_request_count set to something greater then 1 to allow reusing.
Parameters
[in]settingsThe OlpClientSettings instance.
[in]urlThe url of the host.
[in]callbackThe user callback will be called when request completed.

The documentation for this class was generated from the following file: