-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
93 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
|
||
default_app_config = 'health_check.contrib.rmq.apps.HealthCheckConfig' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# -*- coding: utf-8 -*- | ||
from django.apps import AppConfig | ||
|
||
from health_check.plugins import plugin_dir | ||
|
||
|
||
class HealthCheckConfig(AppConfig): | ||
name = 'health_check.contrib.rmq' | ||
|
||
def ready(self): | ||
from .backends import RMQHealthCheck | ||
plugin_dir.register(RMQHealthCheck) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
import logging | ||
import pika | ||
|
||
from django.conf import settings | ||
|
||
from health_check.backends import BaseHealthCheckBackend | ||
from health_check.exceptions import ServiceUnavailable | ||
|
||
class RMQHealthCheck(BaseHealthCheckBackend): | ||
def check_status(self): | ||
logger = logging.getLogger(__name__) | ||
try: | ||
pika.BlockingConnection(pika.ConnectionParameters(settings.HEALTH_CHECK_CONF['rmq_host'])) | ||
except Exception, e: | ||
raise ServiceUnavailable("Connection Error") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
|
||
default_app_config = 'health_check.contrib.sqs.apps.HealthCheckConfig' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# -*- coding: utf-8 -*- | ||
from django.apps import AppConfig | ||
|
||
from health_check.plugins import plugin_dir | ||
|
||
|
||
class HealthCheckConfig(AppConfig): | ||
name = 'health_check.contrib.sqs' | ||
|
||
def ready(self): | ||
from .backends import SQSHealthCheck | ||
plugin_dir.register(SQSHealthCheck) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# -*- coding: utf-8 -*- | ||
import logging | ||
from django.conf import settings | ||
from health_check.backends import BaseHealthCheckBackend | ||
from health_check.exceptions import ServiceUnavailable | ||
import boto3 | ||
|
||
|
||
class SQSHealthCheck(BaseHealthCheckBackend): | ||
logger = logging.getLogger(__name__) | ||
|
||
def check_status(self): | ||
try: | ||
sqs = boto3.resource('sqs', | ||
region_name=settings.HEALTH_CHECK_CONF['region_name'], | ||
aws_secret_access_key=settings.HEALTH_CHECK_CONF['aws_secret_access_key'], | ||
aws_access_key_id=settings.HEALTH_CHECK_CONF['aws_access_key_id'] | ||
) | ||
q = sqs.get_queue_by_name(QueueName=settings.HEALTH_CHECK_CONF['sqs_queue_name']) | ||
except Exception, e: | ||
ServiceUnavailable("connection error") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,5 @@ pep8 | |
pep8-naming | ||
pytest | ||
pytest-django | ||
pika | ||
boto3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters