-
Notifications
You must be signed in to change notification settings - Fork 53
Feature Flag Setup
The feature flag setup allows developers to deploy new functionality in dark and later launch the feature live by turning the flag on. The current setup also allows the frontend and the backend to share the same source of truth hence being always in sync.
Using this setup will launch the feature at the application/org/facility level. If you need to launch a feature at the user level another method using okta groups has been used in the past.
The setup consists of 3 main pieces:
-
FeatureFlagsConfig
object. -
GET /feature-flags
REST endpoint. -
WithFeatureFlags
react context.
When the server starts this object loads the flag values that have been setup in the application yaml under the features property. To have access to the feature flags on the Java code import this object as part of the Java class that needs access (example of integration with Java class).
When creating a new flag, besides adding the flag and its value as a property to the yaml file, you also need to add it as a new property of this object.
As an optional capability this configuration object can be set up to retrieve the flag value from the database every minute allowing the possibility of turning on a feature without the need of a redeployment or a server restart (both things are needed when relying on setting the flag through the yaml only). This extra setup is done by adding a new entry to the feature_flag table in our DB and adding the logic to map that entry value to the config object.
The backend exposes a GET /feature-flags endpoint (through the FeatureFlagsController.java) which returns a JSON with all the flags and their values to the UI. No change is needed in this service when adding a new flag as it will automatically reflect the new additions in the response.
In the UI side the application uses the flagged
library to implement a react context called WithFeatureFlags.tsx that takes care of calling the /feature-flags endpoint on load and injecting the flag values in the application's root component. Through the use of the useFeature
hook any component in SimpleReport can access any flag value (example of integration with react component).
As mentioned in the FeatureFlagsConfig section. This setup also has the capability to set the flag value in the database to allow the launch of a feature without the need of code changes (updates to the yaml) and redeployments.
To support this load of values the backend also counts with a FeatureFlag.java which is the model to represent an entry from the feature_flag table, and the FeatureFlagRepository.Java with is the object used to connect and retrieve the values to the database.
- Getting Started
- [Setup] Docker and docker compose development
- [Setup] IntelliJ run configurations
- [Setup] Running DB outside of Docker (optional)
- [Setup] Running nginx locally (optional)
- [Setup] Running outside of docker
- Accessing and testing weird parts of the app on local dev
- Accessing patient experience in local dev
- API Testing with Insomnia
- Cypress
- How to run e2e locally for development
- E2E tests
- Database maintenance
- MailHog
- Running tests
- SendGrid
- Setting up okta
- Sonar
- Storybook and Chromatic
- Twilio
- User roles
- Wiremock
- CSV Uploader
- Log local DB queries
- Code review and PR conventions
- SimpleReport Style Guide
- How to Review and Test Pull Requests for Dependabot
- How to Review and Test Pull Requests with Terraform Changes
- SimpleReport Deployment Process
- Adding a Developer
- Removing a developer
- Non-deterministic test tracker
- Alert Response - When You Know What is Wrong
- What to Do When You Have No Idea What is Wrong
- Main Branch Status
- Maintenance Mode
- Swapping Slots
- Monitoring
- Container Debugging
- Debugging the ReportStream Uploader
- Renew Azure Service Principal Credentials
- Releasing Changelog Locks
- Muting Alerts
- Architectural Decision Records
- Backend Stack Overview
- Frontend Overview
- Cloud Architecture
- Cloud Environments
- Database ERD
- External IDs
- GraphQL Flow
- Hibernate Lazy fetching and nested models
- Identity Verification (Experian)
- Spring Profile Management
- SR Result bulk uploader device validation logic
- Test Metadata and how we store it
- TestOrder vs TestEvent
- ReportStream Integration
- Feature Flag Setup
- FHIR Resources
- FHIR Conversions
- Okta E2E Integration
- Deploy Application Action
- Slack notifications for support escalations
- Creating a New Environment Within a Resource Group
- How to Add and Use Environment Variables in Azure
- Web Application Firewall (WAF) Troubleshooting and Maintenance
- How to Review and Test Pull Requests with Terraform Changes