diff --git a/heroku_connect/contrib/heroku_connect_health_check/backends.py b/heroku_connect/contrib/heroku_connect_health_check/backends.py index 8e54974c..a4d5f314 100644 --- a/heroku_connect/contrib/heroku_connect_health_check/backends.py +++ b/heroku_connect/contrib/heroku_connect_health_check/backends.py @@ -3,7 +3,7 @@ import logging from ...conf import settings -from ...utils import get_connections +from ... import utils try: from health_check.backends import BaseHealthCheckBackend @@ -24,9 +24,9 @@ def check_status(self): if not (settings.HEROKU_AUTH_TOKEN and settings.HEROKU_CONNECT_APP_NAME): raise ServiceUnavailable('Both App Name and Auth Token are required') - connections = get_connections(settings.HEROKU_CONNECT_APP_NAME) + connections = utils.get_connections(settings.HEROKU_CONNECT_APP_NAME) for connection in connections: - if connection['state'] != 'IDLE': + if connection['state'] not in utils.ConnectionStates.OK_STATES: self.add_error(ServiceUnavailable( "Connection state for '%s' is '%s'" % ( connection['name'], connection['state'] diff --git a/heroku_connect/utils.py b/heroku_connect/utils.py index 00c0789c..7570f7d5 100644 --- a/heroku_connect/utils.py +++ b/heroku_connect/utils.py @@ -8,6 +8,18 @@ from .conf import settings +class ConnectionStates: + IDLE = 'IDLE' + POLLING_DB_CHANGES = 'POLLING_DB_CHANGES' + IMPORT_CONFIGURATION = 'IMPORT_CONFIGURATION' + + OK_STATES = ( + IDLE, + POLLING_DB_CHANGES, + IMPORT_CONFIGURATION, + ) + + def get_mapping(version=1, exported_at=None): """ Return Heroku Connect mapping for the entire project.