Vai al contenuto

The status of a service

As already written in the Microservices vademecum, we care a lot about the services healthy state.

For this purpose we developed a new core-service, the Doctor service
alt image.

Doctor service purpose

The purpose of the doctor service is to do a complete check of the services status in the project in which is deployed.

To do this, the service will call a specific route, the /-/check-up one.

Warning

NB. the Doctor service is the only one who can call the /-/check-up route of services.

NEVER call the /-/check-up route of a service from the checkUpHandler of another service, the risk is to start a /-/check-up calls loop.

Doctor service results

The Doctor service has two possible results:

  • 200: OK → all services are healthy and can do their job at 100%

    {
      "auth-service": {
       "name": "auth-validator",
       "status": "OK",
       "version": "1.2.0"
      },
      "a-beautiful-service": {
       "name": "a-beautiful-service",
       "status": "OK",
       "version": "0.1.7"
      }
    }
    
  • 503: KO → one or more services are not completely OK

    {
      "auth-service": {
        "name": "auth-validator",
        "status": "OK",
        "version": "1.2.0"
      },
      "microservice-gateway": {
        "error": {
          "type": "INVALID_STATUS_CODE",
          "statusCode": 404
        }
      },
      "mongodb-reader": {
        "error": {
            "type": "INVALID_STATUS_CODE",
            "statusCode": 404
        }
      }
    }
    

As can be seen from the above examples the result, regardless of the status code, will contain the /-/check-up response of each called service.