Control feature rollout for certain user segments of your application with feature flags. To start using feature management in the platform, follow the instructions below to install the SDK and deploy a feature flag.
Install the SDK
Follow these steps to install the SDK:
-
Select
. -
Select an Environment from the options, or create an environment by completing the following:
-
Select Create environment.
-
Enter an Environment name.
-
(Optional) Enter a Description.
-
(Optional) Select Approvers if you want to have a manual approval required before deployment.
-
(Optional) Enter any Properties you want to associate with the environment. For more information, refer to properties configuration and properties in an environment.
-
Select Submit.
-
-
Select C/C++ as the language.
-
Choose your installation method: Download prebuilt binaries or build from source.
Install the CloudBees feature management SDK
The CloudBees feature management SDK for C/C++ can be installed by building from source.
To install the CloudBees feature management SDK:
-
Clone the CloudBees feature management C++ SDK repository:
git clone https://github.com/cloudbees/rox-cpp-sdk.git cd rox-cpp-sdk
-
Build the SDK:
mkdir build && cd build cmake .. make
-
Install the SDK:
sudo make install
-
Link it in your C++ project:
g++ -o my_app my_app.cpp -lrox_sdk -lpthread
Add feature flags to a C/C++ application
Follow these steps to configure feature flags using the SDK:
-
Include the CloudBees feature management SDK headers.
-
Initialize feature flag variables.
-
Register the feature flags.
-
Set up the SDK using your environment key.
-
Add feature flags to your application using the C or C++ code, as appropriate. For example:
#include <rox/server/rox_server.h> #include <rox/server/flags/rox_flag.h> #include <rox/server/values/rox_string.h> #include <rox/server/values/rox_int.h> #include <rox/server/values/rox_double.h> #include <stdio.h> typedef struct { RoxFlag enable_tutorial; RoxString title_color; RoxInt page; RoxDouble percentage; } FeatureFlags; int main() { // Initialize feature flags FeatureFlags flags; flags.enable_tutorial = rox_flag_create(false); flags.title_color = rox_string_create("White", "White", "Blue", "Green", "Yellow", NULL); flags.page = rox_int_create(1, 1, 2, 3, NULL); flags.percentage = rox_double_create(99.9, 10.5, 50.0, 99.9, NULL); // Register the feature flags rox_register("enable_tutorial", flags.enable_tutorial); rox_register("title_color", flags.title_color); rox_register("page", flags.page); rox_register("percentage", flags.percentage); // Setup the SDK (Replace <YOUR-SDK-KEY> with the actual key) rox_setup("<YOUR-SDK-KEY>"); (1) // Example usage printf("Feature flag 'enable_tutorial' is %s\n", rox_flag_is_enabled(flags.enable_tutorial) ? "enabled" : "disabled"); printf("Selected title color: %s\n", rox_string_get_value(flags.title_color)); printf("Selected page: %d\n", rox_int_get_value(flags.page)); printf("Selected percentage: %.2f\n", rox_double_get_value(flags.percentage)); // Clean up rox_flag_free(flags.enable_tutorial); rox_string_free(flags.title_color); rox_int_free(flags.page); rox_double_free(flags.percentage); rox_shutdown(); return 0; }
#include <rox/server/rox_server.h> #include <rox/server/flags/rox_flag.h> #include <rox/server/values/rox_string.h> #include <rox/server/values/rox_int.h> #include <rox/server/values/rox_double.h> #include <iostream> using namespace std; class FeatureFlags { public: FeatureFlags() : enableTutorial(false), titleColor("White", {"White", "Blue", "Green", "Yellow"}), page(1, {1, 2, 3}), percentage(99.9, {10.5, 50.0, 99.9}) {} RoxFlag enableTutorial; RoxString titleColor; RoxInt page; RoxDouble percentage; }; int main() { FeatureFlags flags; // Register the flags RoxServer::Register(&flags); // Setup the SDK (Replace <YOUR-SDK-KEY> with the actual key) RoxServer::Setup("<YOUR-SDK-KEY>"); (1) // Example usage cout << "Feature flag 'enableTutorial' is " << (flags.enableTutorial.IsEnabled() ? "enabled" : "disabled") << endl; cout << "Selected title color: " << flags.titleColor.GetValue() << endl; cout << "Selected page: " << flags.page.GetValue() << endl; cout << "Selected percentage: " << flags.percentage.GetValue() << endl; return 0; }
1 | The CloudBees platform provides the unique SDK key for your environment at the <YOUR-SDK-KEY> location inside the RoxServer::Setup() call. |
Run the application and test the integration
To verify that the SDK integration is working, follow these steps:
-
Compile and run your application:
g++ -o my_app my_app.cpp -L./lib -lrox_sdk -lpthread ./my_app
For Windows using MinGW, replace ./my_app
withmy_app.exe
. -
In the CloudBees platform, select Test integration.
This will verify that the SDK is properly communicating with the CloudBees Feature Management service.
-
Check your feature flags in the CloudBees platform UI.
After running your application for the first time, any feature flags added in the code will automatically appear in the Feature management dashboard.
You have successfully installed the C/C++ SDK and added feature flags to your application!