feat(chalice): health-check for kafka
This commit is contained in:
parent
1053e750db
commit
c1ec53c39e
2 changed files with 8 additions and 10 deletions
|
|
@ -2,8 +2,8 @@ from urllib.parse import urlparse
|
||||||
|
|
||||||
import redis
|
import redis
|
||||||
import requests
|
import requests
|
||||||
|
from confluent_kafka.admin import AdminClient
|
||||||
from decouple import config
|
from decouple import config
|
||||||
import kafka
|
|
||||||
|
|
||||||
from chalicelib.utils import pg_client, ch_client
|
from chalicelib.utils import pg_client, ch_client
|
||||||
|
|
||||||
|
|
@ -229,12 +229,11 @@ def __check_kafka():
|
||||||
return fail_response
|
return fail_response
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# consumer = kafka.KafkaConsumer(group_id='test', bootstrap_servers=[config("KAFKA_SERVERS")])
|
a = AdminClient({'bootstrap.servers': config("KAFKA_SERVERS"), "socket.connection.setup.timeout.ms": 3000})
|
||||||
# topics = consumer.topics()
|
topics = a.list_topics().topics
|
||||||
#
|
if not topics:
|
||||||
# if not topics:
|
raise Exception('topics not found')
|
||||||
# raise RuntimeError()
|
|
||||||
client =kafka.KafkaClient(bootstrap_servers=[config("KAFKA_SERVERS")])
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("!! Issue getting kafka-health response")
|
print("!! Issue getting kafka-health response")
|
||||||
print(str(e))
|
print(str(e))
|
||||||
|
|
@ -243,6 +242,5 @@ def __check_kafka():
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"health": True,
|
"health": True,
|
||||||
"details": {"version": r.execute_command('INFO')['redis_version']}
|
"details": {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,4 +19,4 @@ python3-saml==1.15.0
|
||||||
python-multipart==0.0.5
|
python-multipart==0.0.5
|
||||||
|
|
||||||
redis==4.5.1
|
redis==4.5.1
|
||||||
kafka-python==2.0.2
|
confluent-kafka==2.0.2
|
||||||
Loading…
Add table
Reference in a new issue