Minimal Spring Boot application using the Flagent Spring Boot Starter for feature flag evaluation.
- Single evaluation - Evaluate a flag via
FlagentEvaluationFacade - EntityContext - Constraint-based targeting (country, tier)
- Batch evaluation - Evaluate multiple flags for multiple entities
- Caching - Optional in-memory cache (Caffeine)
- JDK 21+
- Flagent backend running on
http://localhost:18000
From repo root:
./gradlew :backend:runFrom repo root:
./gradlew :sample-spring-boot:bootRunThe sample starts on http://localhost:8080.
See src/main/resources/application.yml:
server:
port: 8080
flagent:
base-url: http://localhost:18000
cache:
enabled: true
ttl-ms: 60000Override flagent.base-url if Flagent runs elsewhere.
# Basic
curl "http://localhost:8080/eval?flagKey=my_flag&entityId=user-1"
# With entityContext for constraint-based targeting
curl "http://localhost:8080/eval?flagKey=my_flag&entityId=user-1&country=US&tier=premium"curl -X POST http://localhost:8080/eval/batch \
-H "Content-Type: application/json" \
-d '{
"entities": [
{"entityID": "user1", "entityType": "user", "entityContext": {"country": "US", "tier": "premium"}},
{"entityID": "user2", "entityType": "user", "entityContext": {"country": "EU"}}
],
"flagKeys": ["my_flag", "experiment_1"]
}'Convenience endpoint with pre-defined entities:
curl "http://localhost:8080/eval/batch-demo?flagKey=my_flag"| Endpoint | Method | Description |
|---|---|---|
/eval |
GET | Single evaluation. Params: flagKey, entityId, entityType, country, tier |
/eval/batch |
POST | Batch evaluation (JSON body) |
/eval/batch-demo |
GET | Batch demo with sample entities |
When your flag has segments with constraints (e.g., country EQ US), pass country and tier as query params. The evaluator matches the segment and returns the assigned variant.
spring-boot/
├── src/main/java/com/flagent/sample/
│ ├── EvalController.java # Evaluation endpoints
│ └── SpringBootSampleApplication.java
├── src/main/resources/
│ └── application.yml
├── build.gradle.kts
└── README.md
- Connection refused: Ensure Flagent backend is running at
http://localhost:18000 - 404 on evaluation: Create a flag in Flagent UI first (e.g., key
my_flag)
Apache 2.0 - See parent project license