blob: 612d66119665274e8ae5c310db04c492026ecb09 [file] [log] [blame]
Thomas Lee S9f0da512019-09-27 21:09:25 +05301#
2# Copyright 2017 the original author or authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16from SimpleHTTPServer import SimpleHTTPRequestHandler
17from structlog import get_logger
18from connection_mgr import ConnectionManager
19log = get_logger()
20
21class Probe(SimpleHTTPRequestHandler):
22
23 def do_GET(self):
24
25 if self.path == '/healthz':
26 self.health_probe()
27
28 elif self.path == '/readz':
29 self.ready_probe()
30
31 def health_probe(self):
32
33 if ConnectionManager.liveness_probe():
34 self.send_response(200)
35 self.end_headers()
36 else :
37 self.send_response(418)
38 self.end_headers()
39
40 def ready_probe(self):
41
42 if ConnectionManager.readiness_probe():
43 self.send_response(200)
44 self.end_headers()
45 else :
46 self.send_response(418)
47 self.end_headers()