Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added a heartbeat API

  • Loading branch information...
commit a76bed2baa8b94d7c5a526c738f0b090d17a454b 1 parent 4401442
@tarekziade tarekziade authored
Showing with 14 additions and 0 deletions.
  1. +5 −0 monolith/web/tests/tests_views.py
  2. +9 −0 monolith/web/views.py
View
5 monolith/web/tests/tests_views.py
@@ -77,3 +77,8 @@ def test_query_time_invalid_json(self):
res = self.app.post('/v1/time', '{"que"""', expect_errors=True)
self.assertEqual(res.status_code, 400)
self.assertEqual(res.json['status'], 'error')
+
+ def test_hb(self):
+ res = self.app.get('/__heartbeat__')
+ self.assertEqual(res.status_code, 200)
+ self.assertEqual(res.json['status'], 'OK')
View
9 monolith/web/views.py
@@ -14,6 +14,7 @@ class ElasticSearchQuery(MappingSchema):
names = SchemaNode(Seq(), location='body')
+
info = Service(name='info', path='/',
cors_policy={'origins': ('*',), 'credentials': True})
@@ -52,3 +53,11 @@ def query_es_time(request):
request.errors.status = e.status_code
request.errors.add('body', description=e.error)
return {}
+
+
+heartbeat = Service(name='hb', path='/__heartbeat__')
+
+
+@heartbeat.get(renderer='json')
+def heartbeat(request):
+ return {'status': 'OK'}
Please sign in to comment.
Something went wrong with that request. Please try again.