The OlpClientSettings class pulls together all the settings for customization of the client library behavior.
You need to create the OlpClientSettings object to get catalog and partition metadata, retrieve versioned, volatile, and stream layer data, and publish data to the HERE platform.
To create OlpClientSettings object:
-
To perform requests asynchronously, create the
TaskSchedulerobject.std::shared_ptr<olp::thread::TaskScheduler> task_scheduler = olp::client::OlpClientSettingsFactory::CreateDefaultTaskScheduler(1u); -
To internally operate with the HERE platform Services, create the
Networkclient.std::shared_ptr<olp::http::Network> http_client = olp::client:: OlpClientSettingsFactory::CreateDefaultNetworkRequestHandler();The
Networkclient is designed and intended to be shared. -
To configure handling of failed requests, create the
RetrySettingsobject with the following parameters:retry_condition– the HTTP status codes that you want to retry.backdown_strategy– the delay between retries.max_attempts– the number of attempts.timeout– the connection timeout limit (in seconds).initial_backdown_period– the period between the error and the first retry attempt (in milliseconds).
We recommend that your application includes retry logic for handling HTTP 429 and 5xx errors. Use exponential backoff in the retry logic.
olp::client::RetrySettings retry_settings; retry_settings.retry_condition = [](const olp::client::HttpResponse& response) { return olp::http::HttpStatusCode::TOO_MANY_REQUESTS == response.status; }; retry_settings.backdown_strategy = olp::client::ExponentialBackdownStrategy(); retry_settings.max_attempts = 3; retry_settings.timeout = 60; retry_settings.initial_backdown_period = 200;
-
Authenticate to the HERE platform.
-
(Optional) To configure a cache:
-
Create the
CacheSettingsinstance with the cache that you want to enable and, if needed, the maximum cache size in bytes.By default, the downloaded data is cached in memory, and the maximum size of it is 1 MB.
olp::cache::CacheSettings cache_settings; // On iOS, the path is relative to the Application Data folder. cache_settings.disk_path_mutable = "path to mutable cache"; cache_settings.disk_path_protected = "path to protected cache"; cache_settings.max_disk_storage = 1024ull * 1024ull * 32ull;
-
Add the
CacheSettingsinstance to theDefaultCacheconstructor.olp::client::OlpClientSettingsFactory::CreateDefaultCache(cache_settings);To learn how to get or change cache size, see Work with a cache.
-
-
Set up the
OlpClientSettingsobject, and if you want to add the expiration limit for the data that is stored in the cache, set thedefault_cache_expirationto the needed expiration time.By default, expiration is disabled.
You can only disable expiration for the mutable and in-memory cache. This setting does not affect the protected cache as no entries are added to the protected cache in the read-only mode.
olp::client::OlpClientSettings client_settings; client_settings.authentication_settings = auth_settings; client_settings.task_scheduler = task_scheduler; client_settings.network_request_handler = http_client; client_settings.retry_settings = retry_settings; client_settings.cache = olp::client::OlpClientSettingsFactory::CreateDefaultCache(cache_settings); client_settings.default_cache_expiration = std::chrono::seconds(200);