Skip to content

Commit

Permalink
Fix #37 -- Add complete list of expected connection states
Browse files Browse the repository at this point in the history
  • Loading branch information
codingjoe committed Jan 24, 2018
1 parent 4115581 commit 126a193
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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']
Expand Down
12 changes: 12 additions & 0 deletions heroku_connect/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 126a193

Please sign in to comment.