diff options
author | Valery Piashchynski <[email protected]> | 2021-04-04 18:39:52 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-04-04 18:39:52 +0300 |
commit | cc56299b877f3fbbae1e3368d98804d06564a424 (patch) | |
tree | 6b2bcd13eb32e31cef556f57869b9dcdeea4472a /plugins/http | |
parent | c1664e0815727e599dcb7f7a0a7a95a5be974197 (diff) |
- 🔥 Support Readiness checks (via `/ready`) status plugin endpoint.
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'plugins/http')
-rw-r--r-- | plugins/http/plugin.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/plugins/http/plugin.go b/plugins/http/plugin.go index 82cf76ed..13a76329 100644 --- a/plugins/http/plugin.go +++ b/plugins/http/plugin.go @@ -405,7 +405,25 @@ func (s *Plugin) Status() status.Status { } // if there are no workers, threat this as error return status.Status{ - Code: http.StatusInternalServerError, + Code: http.StatusNoContent, + } +} + +// Status return status of the particular plugin +func (s *Plugin) Ready() status.Status { + workers := s.Workers() + for i := 0; i < len(workers); i++ { + // If state of the worker is ready (at least 1) + // we assume, that plugin's worker pool is ready + if workers[i].State().Value() == worker.StateReady { + return status.Status{ + Code: http.StatusOK, + } + } + } + // if there are no workers, threat this as no content error + return status.Status{ + Code: http.StatusNoContent, } } |