Add a status option to the service health check
This commit is contained in:
parent
61325d7b91
commit
46c266661c
17 changed files with 97 additions and 2 deletions
|
@ -173,10 +173,14 @@ func (shc *ServiceHealthChecker) checkHealthHTTP(ctx context.Context, target *ur
|
|||
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusBadRequest {
|
||||
if shc.config.Status == 0 && (resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusBadRequest) {
|
||||
return fmt.Errorf("received error status code: %v", resp.StatusCode)
|
||||
}
|
||||
|
||||
if shc.config.Status != 0 && shc.config.Status != resp.StatusCode {
|
||||
return fmt.Errorf("received error status code: %v expected status code: %v", resp.StatusCode, shc.config.Status)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue