Driving Idea: Have a centralized toggle server with in-memory db and REST API for retrieving real-time toggle values.
Why? The pursuit (and necessity) of Trunk Based Development. See Feature Flags, especially Runtime Switchable.
Goals:
- server:
- REST API for toggle values
- provide consumable client jar
- Have UI for toggle management (set, add, remove)
- Have in-memory and persistent toggle storage for server
- SSE impl for toggle changes
- client jar (consumed in client-service):
- Provide a method such as
ToggleClient.isFeatureEnabled("my-toggle")
that gets the first available value:- server value
application.properties
on classpath of client-service- default to false
- Provide a method such as
The toggle-server
project contains the api-<lang>-<protocol>
subprojects, collectively producing:
- build/libs/toggle-server-${version}.war
- api-java-rest/build/libs/api-java-rest-${version}.jar
- api-java-sse/build/libs/api-java-sse-${version}.jar
- ...
# from toggle-server directory
./gradlew clean build
# from sample-client-service directory
./gradlew clean build
Fast dev workflow; Run Server, UI, and Sample Client separately
# from toggle-server directory
./gradlew bootRun
Request toggle value with a url like:
http://localhost:8090/toggle-server/get-toggle?toggleId=my-feature
Allows file-watching for ui changes; No rebuilds needed.
# from toggle-server/ui directory
npm start
On startup, this should automatically open the ui at http://localhost:3000/
# from sample-client-service directory
./gradlew bootRun
Visit the following url:
http://localhost:8900/sample-client-service
Slower startup; Run Server/UI as one deployable war.
Currently, cargoRunLocal
gradle task doesn't show the slf4j logs.
Haven't gotten around to configuring log properties.
# from toggle-server directory
./gradle cargoRunLocal -i
Visit the following url: