NCIOCPL / NCI.OCPL.Api.Shared

Common code shared between APIs
0 stars 1 forks source link

Enabler: Create common ESHealthCheck service #45

Closed blairlearn closed 1 year ago

blairlearn commented 1 year ago

Create reusable code for checking Elasticsearch health.

We need to create "health check" endpoints for the various APIs. It would be good to avoid writing the same code multiple times, so instead, we'll create a class in NCI.OCPL.Api.Common to perform the most common checks and individual services can create instances of this class as needed.

The most common (only?) check we do at this time is to check the host/cluster health by checking index health.


⚠️ I need to think on this a bit. Instead of a string, the constructor should take an object with a method/property returning string. Then we don't need lots of hijinks in the startup code to instantiate the thing.



classDiagram

    class IHealthCheckService {
        <<interface>>
        IsHealthy() bool
    }

    class ESHealthCheckService {
        +ESHealthCheckService(esClient, indexName, logger)
        +IsHealthy() bool
    }

    ESHealthCheckService <|-- IHealthCheckService

The ESHealthCheckService constructor takes as parameters an instance of IElasticClient, the name of the specific index to check, and an instance of ILogger<ESHealthCheck>.

The IsHealthy method returns true if the index is healthy and false otherwise.

ESTIMATE TBD

Resources:

Prerequisites

Sub-Tasks

Notes

blairlearn commented 1 year ago

Completed in 52446d9b89d5d72a6f6063c02335c5764be42ebb