Unleash Client SDK for C++
This repository provides a C++ client SDK for Unleash that meets the Unleash Client Specifications.
Features
The below table shows what features the SDKs support or plan to support.
- Feature toggles
- Built-in strategies
- Unleash context
- Custom strategies
- Strategy constrains
- Variants
- Usage Metrics
Requirements
- Compatible C++17 compiler such as Clang or GCC. The minimum required versions are Clang 4 and g++7.
Usage
Include Unleash library
#include
Initialization
The unleashClient
can be initialized with the following parameters but only appName
and unleashServerUrl
are mandatories.
Config | Required? | Type | Default value |
---|---|---|---|
Unleash URL | Yes | String | N/A |
App. Name | Yes | String | N/A |
Instance ID. | No | String | N/A |
Environment | No | String | N/A |
Authentication | No | String | N/A |
Refresh Interval (ms) | No | Int | 15000 |
unleash::UnleashClient unleashClient = unleash::UnleashClient::create("appName", "unleashServerUrl").instanceId("intanceId").environment("environment").authentication("token).refreshInterval("pollingTime");
unleashClient.initializeClient();
Feature Flag is enabled?
- Simple toggle:
unleashClient.isEnabled("feature.toogle");
- Toggle with context:
#include "unleash/context.h"
...
unleash::Context context{"userId", "sessionId", "remoteAddress"}
unleashClient.isEnabled("feature.toogle", context);
Integration
CMake
To be documented
Conan
To be documented. This package is pending to be published in Conan Center as unleash-client-cpp/1.0.0
Tested services
- Gitlab using
application name
andinstance id
parameters for authentication. - Self-hosted unleash using
client token
for authentication.
Used third-party tools
Thanks a lot to the following tools for your contribution:
- Building a Dual Shared and Static Library with CMake for the CMake library template.
- C++ Requests: Curl for People for the API client library.
- JSON for Modern C++ for the JSON handling library.
- Codecov for code coverage solution.
- Sonarcloud for the static code analysis.
- CMake for the C++ build system.
- Conan.io for the C++ package manager.
- GitHub for the repository and CI/CD services.