[MM-16032] Add system ping endpoint health checks (#11267)
* Add system ping endpoint health checks This change adds the option for additional server health checks to be performed when the system ping endpoint is hit. An additional field 'getserverstatus' is required to run the enhanced health checks to ensure previous default ping behavior is not modified. * Use snake_casing
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
a9b4a7f508
Коммит
41e5ec3c5e
@@ -35,6 +35,7 @@ const (
|
||||
STATUS = "status"
|
||||
STATUS_OK = "OK"
|
||||
STATUS_FAIL = "FAIL"
|
||||
STATUS_UNHEALTHY = "UNHEALTHY"
|
||||
STATUS_REMOVE = "REMOVE"
|
||||
|
||||
CLIENT_DIR = "client"
|
||||
@@ -2682,7 +2683,22 @@ func (c *Client4) GetPing() (string, *Response) {
|
||||
r, err := c.DoApiGet(c.GetSystemRoute()+"/ping", "")
|
||||
if r != nil && r.StatusCode == 500 {
|
||||
defer r.Body.Close()
|
||||
return "unhealthy", BuildErrorResponse(r, err)
|
||||
return STATUS_UNHEALTHY, BuildErrorResponse(r, err)
|
||||
}
|
||||
if err != nil {
|
||||
return "", BuildErrorResponse(r, err)
|
||||
}
|
||||
defer closeBody(r)
|
||||
return MapFromJson(r.Body)["status"], BuildResponse(r)
|
||||
}
|
||||
|
||||
// GetPingWithServerStatus will return ok if several basic server health checks
|
||||
// all psss successfully.
|
||||
func (c *Client4) GetPingWithServerStatus() (string, *Response) {
|
||||
r, err := c.DoApiGet(c.GetSystemRoute()+"/ping?get_server_status=true", "")
|
||||
if r != nil && r.StatusCode == 500 {
|
||||
defer r.Body.Close()
|
||||
return STATUS_UNHEALTHY, BuildErrorResponse(r, err)
|
||||
}
|
||||
if err != nil {
|
||||
return "", BuildErrorResponse(r, err)
|
||||
|
||||
Ссылка в новой задаче
Block a user