This repository provides a C++ client SDK for Unleash that meets the Unleash Client Specifications.
The below table shows what features the SDKs support or plan to support.
- Feature toggles
- Built-in strategies
- Unleash context
- Strategy constrains
- Application registration
- Usage Metrics
- Variants
- Custom stickiness
- Compatible C++17 compiler such as Clang or GCC. The minimum required versions are Clang 4 and g++7.
#include <unleash/unleashclient.h>
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();
- Simple toggle:
unleashClient.isEnabled("feature.toogle");
- Toggle with context:
#include "unleash/context.h"
...
unleash::Context context{"userId", "sessionId", "remoteAddress"}
unleashClient.isEnabled("feature.toogle", context);
The following requirements need to be installed to build the library using CMake:
- CMake 3.19+
- Conan 2 (CMakeDeps Generator)
By default, it provides the static library. The shared version shall be available using the CMake
option BUILD_SHARED_LIB=YES
.
The installation files include the UnleashConfig.cmake
to integrate this library using the target unleash::unleash
.
To build unleash client with conan and CMake run the following commands:
conan install . --build=missing --settings=build_type=Debug
cmake -S . --preset conan-debug
cmake --build --preset conan-debug
ctest --preset conan-debug
Substitute Debug
for Release
to build the release version. The CMAKE_PREFIX_PATH
and --output-folder
parameters should point to the same directory, make sure to use an absolute path for the CMAKE_PREFIX_PATH
.
This package is published in Conan Center as unleash-client-cpp/1.1.1.
- Gitlab using
application name
andinstance id
parameters for authentication. - Self-hosted unleash using
client token
for authentication.
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.