Skip to content

Commit

Permalink
Ref #37 -- Add more expected connection states (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
codingjoe authored Jan 24, 2018
1 parent 17e4c2e commit d8eb79b
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@

import logging

from ... import utils
from ...conf import settings
from ...utils import get_connections

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']
13 changes: 13 additions & 0 deletions heroku_connect/utils.py
Original file line number Diff line number Diff line change
@@ -8,6 +8,19 @@
from .conf import settings


class ConnectionStates:
IDLE = 'IDLE'
POLLING_DB_CHANGES = 'POLLING_DB_CHANGES'
IMPORT_CONFIGURATION = 'IMPORT_CONFIGURATION'
NEED_AUTHENTICATION = 'NEED_AUTHENTICATION'

OK_STATES = (
IDLE,
POLLING_DB_CHANGES,
IMPORT_CONFIGURATION,
)


def get_mapping(version=1, exported_at=None):
"""
Return Heroku Connect mapping for the entire project.

0 comments on commit d8eb79b

Please sign in to comment.