launchdarkly / cpp-sdks

C++ Client/Server SDKs
Other
5 stars 2 forks source link
c cpp cpp17 feature-flags feature-toggles launchdarkly launchdarkly-sdk managed-by-terraform sdk

LaunchDarkly monorepo for C++ SDKs.

This repository contains LaunchDarkly SDK packages which are written in C++. This includes shared libraries, used by SDKs and other tools, as well as SDKs.

Packages

Readme issues tests docs latest release
libs/client-sdk C++ Client SDK Actions Status Documentation On Github
libs/server-sdk C++ Server SDK Actions Status Documentation On Github
libs/server-sdk-redis-source C++ Server SDK - Redis Source Actions Status Documentation On Github
Shared packages issues tests
libs/common Common Actions Status
libs/internal Internal Actions Status
libs/server-sent-events Common Server-Sent-Events Actions Status

Organization

Directory Description
.github Contains CI and release process workflows and actions.
examples Contains examples (hello-world style).
contract-tests Contains contract test service.
cmake Contains cmake files for importing and configuring external libraries.
libs Contains library implementations. This includes libraries shared within the project as well as SDK libraries like the client-sdk.
scripts Contains scripts used in the release process.
vendor Contains third party source which is directly integrated into the project. Generally third party source is included through CMake using FetchContent, but some libraries require modification specific to this repository.

Build Requirements

Dependencies

  1. C++17 and above
  2. CMake 3.19 or higher
  3. Ninja (if using the included build scripts)
  4. Boost version 1.81 or higher (excluding Boost 1.83, see note below)
  5. OpenSSL

[!NOTE]
Boost 1.83 is not supported due to an incompatibility in Boost.JSON. This issue appears to be resolved in versions prior and subsequent to 1.83.

Additional dependencies are fetched via CMake. For details see the cmake folder.

GoogleTest is used for testing.

For information on integrating an SDK package please refer to the SDK specific README.

CMake Usage

Various CMake options are available to customize the client/server SDK builds.

Option Description Default Requires
BUILD_TESTING Coarse-grained switch; turn off to disable all testing and only build the SDK targets. On N/A
LD_BUILD_UNIT_TESTS Whether C++ unit tests are built. On BUILD_TESTING; NOT LD_BUILD_SHARED_LIBS
LD_TESTING_SANITIZERS Whether sanitizers should be enabled. On LD_BUILD_UNIT_TESTS
LD_BUILD_CONTRACT_TESTS Whether the contract test service (used in CI) is built. Off BUILD_TESTING
LD_BUILD_EXAMPLES Whether example apps (hello world) are built. On N/A
LD_BUILD_SHARED_LIBS Whether the SDKs are built as static or shared libraries. Off (static lib) N/A
LD_DYNAMIC_LINK_BOOST If building SDK as shared lib, whether to dynamically link Boost or not. Ensure that the shared boost libraries are present on the target system. On (link boost dynamically when producing shared libs) LD_BUILD_SHARED_LIBS
LD_DYNAMIC_LINK_OPENSSL Whether OpenSSL is dynamically linked or not. Off (static link) N/A
LD_BUILD_REDIS_SUPPORT Whether the server-side Redis Source is built or not. Off N/A

Note: if building the SDKs as shared libraries, then unit tests won't be able to link correctly since the SDK's C++ symbols aren't exposed. To run unit tests, build a static library.

[!WARNING]
When building shared libraries C++ symbols are not exported, only the C API will be exported. This is because C++ does not have a stable ABI.

Basic usage example:

mkdir -p build && cd build
cmake -G"Unix Makefiles" ..

Slightly more advanced example - build shared libraries, and don't build any of the testing components:

mkdir -p build  && cd build
cmake -G"Unix Makefiles" -DLD_BUILD_SHARED_LIBS=On -DBUILD_TESTING=Off ..

The example uses make, but you might instead use Ninja, MSVC, etc.

LaunchDarkly overview

LaunchDarkly is a feature management platform that serves trillions of feature flags daily to help teams build better software, faster. Get started using LaunchDarkly today!

Twitter Follow

Testing

We run integration tests for all our SDKs using a centralized test harness. This approach gives us the ability to test for consistency across SDKs. These tests cover each method in the SDK, and verify that event sending, flag evaluation, stream reconnection, and other aspects of the SDK all behave correctly.

Contributing

We encourage pull requests and other contributions from the community. Check out our contributing guidelines for instructions on how to contribute to this SDK.

About LaunchDarkly