Caching response from Health Endpoint
Why make this change?
Closes #2534
What is this change?
This PR involves creating another parameter in the runtime config which defines the cache-ttl-seconds for the health endpoint.
-
I am using the IMemoryCache to define the cache which has the CacheKey:
HealthCheckResponsein ComprehensiveResponseWriter and saves the serialized version of the response in the cache. -
The changes in Convertor Factory are in respect to the serialization and deserialization of this attribute appropriately. We consider default as 5 seconds in case not provided in the config file. And in case this is 0, caching is disabled.
-
Added timestamp to the health check report
How was this tested?
- [x] Integration Tests
- [x] Unit Tests
Sample Request(s)
Call this CURL
curl --request GET
--url http://localhost:5000/health
--header 'User-Agent: insomnia/10.3.0'
Define the cache value as 5. Then in case of hitting the request without any delay, we get the same response back from the cache. In case hitting after the delay, we get a new response.
/azp run
Azure Pipelines successfully started running 6 pipeline(s).
/azp run
Azure Pipelines successfully started running 6 pipeline(s).
/azp run
Azure Pipelines successfully started running 6 pipeline(s).
/azp run
Azure Pipelines successfully started running 6 pipeline(s).
/azp run
Azure Pipelines successfully started running 6 pipeline(s).
/azp run
Azure Pipelines successfully started running 6 pipeline(s).
/azp run
Azure Pipelines successfully started running 6 pipeline(s).
/azp run
Azure Pipelines successfully started running 6 pipeline(s).
/azp run
Azure Pipelines successfully started running 6 pipeline(s).
/azp run
Azure Pipelines successfully started running 6 pipeline(s).
/azp run
Azure Pipelines successfully started running 6 pipeline(s).
/azp run
Azure Pipelines successfully started running 6 pipeline(s).
/azp run
Azure Pipelines successfully started running 6 pipeline(s).
/azp run
Azure Pipelines successfully started running 6 pipeline(s).
/azp run
Azure Pipelines successfully started running 6 pipeline(s).