data-api-builder icon indicating copy to clipboard operation
data-api-builder copied to clipboard

Caching response from Health Endpoint

Open sezal98 opened this issue 9 months ago • 18 comments

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: HealthCheckResponse in 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.

sezal98 avatar Mar 24 '25 04:03 sezal98

/azp run

sezal98 avatar Apr 07 '25 19:04 sezal98

Azure Pipelines successfully started running 6 pipeline(s).

azure-pipelines[bot] avatar Apr 07 '25 19:04 azure-pipelines[bot]

/azp run

sezal98 avatar Apr 07 '25 19:04 sezal98

Azure Pipelines successfully started running 6 pipeline(s).

azure-pipelines[bot] avatar Apr 07 '25 19:04 azure-pipelines[bot]

/azp run

sezal98 avatar Apr 07 '25 19:04 sezal98

Azure Pipelines successfully started running 6 pipeline(s).

azure-pipelines[bot] avatar Apr 07 '25 19:04 azure-pipelines[bot]

/azp run

Aniruddh25 avatar Apr 07 '25 20:04 Aniruddh25

Azure Pipelines successfully started running 6 pipeline(s).

azure-pipelines[bot] avatar Apr 07 '25 20:04 azure-pipelines[bot]

/azp run

sezal98 avatar Apr 14 '25 14:04 sezal98

Azure Pipelines successfully started running 6 pipeline(s).

azure-pipelines[bot] avatar Apr 14 '25 14:04 azure-pipelines[bot]

/azp run

Aniruddh25 avatar Apr 16 '25 17:04 Aniruddh25

Azure Pipelines successfully started running 6 pipeline(s).

azure-pipelines[bot] avatar Apr 16 '25 17:04 azure-pipelines[bot]

/azp run

sezal98 avatar Apr 28 '25 12:04 sezal98

Azure Pipelines successfully started running 6 pipeline(s).

azure-pipelines[bot] avatar Apr 28 '25 12:04 azure-pipelines[bot]

/azp run

sezal98 avatar Apr 28 '25 13:04 sezal98

Azure Pipelines successfully started running 6 pipeline(s).

azure-pipelines[bot] avatar Apr 28 '25 13:04 azure-pipelines[bot]

/azp run

Aniruddh25 avatar Apr 29 '25 00:04 Aniruddh25

Azure Pipelines successfully started running 6 pipeline(s).

azure-pipelines[bot] avatar Apr 29 '25 00:04 azure-pipelines[bot]

/azp run

Aniruddh25 avatar Apr 29 '25 19:04 Aniruddh25

Azure Pipelines successfully started running 6 pipeline(s).

azure-pipelines[bot] avatar Apr 29 '25 19:04 azure-pipelines[bot]

/azp run

Aniruddh25 avatar Apr 29 '25 22:04 Aniruddh25

Azure Pipelines successfully started running 6 pipeline(s).

azure-pipelines[bot] avatar Apr 29 '25 22:04 azure-pipelines[bot]

/azp run

sezal98 avatar May 06 '25 08:05 sezal98

Azure Pipelines successfully started running 6 pipeline(s).

azure-pipelines[bot] avatar May 06 '25 08:05 azure-pipelines[bot]

/azp run

Aniruddh25 avatar May 07 '25 01:05 Aniruddh25

Azure Pipelines successfully started running 6 pipeline(s).

azure-pipelines[bot] avatar May 07 '25 01:05 azure-pipelines[bot]

/azp run

sezal98 avatar May 07 '25 09:05 sezal98

Azure Pipelines successfully started running 6 pipeline(s).

azure-pipelines[bot] avatar May 07 '25 09:05 azure-pipelines[bot]

/azp run

sezal98 avatar May 09 '25 09:05 sezal98

Azure Pipelines successfully started running 6 pipeline(s).

azure-pipelines[bot] avatar May 09 '25 09:05 azure-pipelines[bot]