Public API for Team Details and Statistics
See Release Notes. |
Business logic
The main purpose of this service is get functionality of teamDetails, teamStatistics, playerStatistics endpoints. Team API provide information about concrete team (participant) for mobile and web LS clients. This information can be: team details (stages and events with this team), team statistics (overall ball possession, goals scored, assists made etc.), player statictics (info about concrete players in the team: ranks of them by goals scoring, assists, red/yellow cards given etc.)
The main advantage is to load and store a full offer in memory
The client response is created only from in-memory data, it allow to avoid slow database queries and minimises response times. Responses are created in special serializer classes
Internal models
Handle next internal models: participant, stage, season, event, region, categorise, actors. Internal models retrieved from kafka topics are written to mongodb collections and Internal cache.
- Kafka
-
Listening five topics: team-api-events', 'team-api-participants', 'team-api-stages', 'team-api-seasons', 'team-api-regions', 'team-api-actors', 'team-api-categories'.
- Mongodb
-
Write resulting models into five collections: participant, stage, season, event, region, actors, categories.
Startup
On application startup firstly we try to load all records from kafka topics (api-short-events, api-participants, api-stage-info, api-season). Process these records and put them into four internal caches.
Internal cache
Loaded from DB (MongoDB) and stored in ConcurrentMap. It’s thread-safety map with high throughput under high concurrency.
CDN cache
Cache lifetime is set in application config file 'cache-control:max-age-seconds':
code-410: 300
details: 10
teamstat: 20
teamsquad: 20
playersstat: 10
nextevent: 10
teamform: 10
leaguetable: 3600
Time presented in seconds.
Metrics
Grafana dashboard: 'Team API prometheus monitoring'.
There are 3 types of metrics: GAUGE, COUNTER, TIMER (contains 2 dimensions: count and sum)
Test REST API Endpoints
Health
Default Actuator endpoint with custom data that specify is caches was initial loaded.
$ http GET 'http://example.com:8088/actuator/health'
HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 302
{
"status" : "UP",
"components" : {
"diskSpace" : {
"status" : "UP",
"details" : {
"total" : 1023599964160,
"free" : 179837513728,
"threshold" : 10485760,
"exists" : true
}
},
"ping" : {
"status" : "UP"
}
}
}