summaryrefslogtreecommitdiff
path: root/plugins/http/plugin.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-04-06 15:27:28 +0300
committerGitHub <[email protected]>2021-04-06 15:27:28 +0300
commit1e33c1fee2a609c9ec28fb5fd2a25b2311103a6f (patch)
tree036884e8f37d3c9abe965e487fe2eecef903ccf2 /plugins/http/plugin.go
parent899936387791bc4c73da5374484c3609b51981a2 (diff)
parentad8db0ad8907fbc562123b41323b34ec6c0dec9f (diff)
Merge pull request #623 from spiral/feature/readiness_probe_healthcheck_endpoint
🔥 feat(status): Readiness checks
Diffstat (limited to 'plugins/http/plugin.go')
-rw-r--r--plugins/http/plugin.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/plugins/http/plugin.go b/plugins/http/plugin.go
index 82cf76ed..86fcb329 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.StatusServiceUnavailable,
+ }
+}
+
+// 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.StatusServiceUnavailable,
}
}