This folder contains sample applications demonstrating how to use the IBM Cloud App Configuration Ruby SDK.
The app.rb file demonstrates how to use the SDK to evaluate feature flags in a continuous loop.
-
Install the SDK dependencies from the root directory:
bundle install
-
Set up your App Configuration service credentials. You'll need:
- Region (e.g.,
us-south,eu-gb) - GUID (Instance ID from service credentials)
- API Key (from service credentials)
- Collection ID (from Collections section)
- Environment ID (from Environments section)
- Region (e.g.,
-
Open
app.rband uncomment the configuration constants at the top of the file (lines 8-12), then add your credentials:REGION = 'us-south' # Your region GUID = 'your-guid' # Your instance GUID APIKEY = 'your-apikey' # Your API key COLLECTION_ID = 'your-collection-id' # Your collection ID ENVIRONMENT_ID = 'your-environment-id' # Your environment ID
-
Update the feature ID in the example (line 64) to match a feature flag in your App Configuration instance:
feature = client.get_feature('your-feature-id')
-
Run the example:
ruby examples/app.rb
The application will continuously evaluate the feature flag and display statistics showing enabled and disabled evaluations. Press Ctrl+C to stop the application.
The example also demonstrates:
- Bootstrap file mode: Uncomment lines 32-35 and comment out lines 24-30 to run offline using a bootstrap configuration file
- Entity attributes: Modify the
entity_attributeshash (lines 59-61) to test segment targeting - Failure simulation: Uncomment the failure simulation blocks (lines 79-89) to test error handling
The application:
- Initializes the App Configuration SDK with your credentials
- Continuously generates random user IDs
- Evaluates a feature flag for each user
- Tracks and displays statistics of enabled vs disabled evaluations
- Demonstrates real-time feature flag evaluation with entity attributes