diff --git a/README.rst b/README.rst index 8e533c1..4ebe4fa 100644 --- a/README.rst +++ b/README.rst @@ -129,6 +129,13 @@ the ``WATCHMAN_CHECKS`` setting. In ``settings.py``:: 'another.module.path.to.callable', ) +You can also import the watchman.constants to include the DEFAULT_CHECKS and PAID_CHECKS in your ``settings.py``:: + + from watchman import constants as watchman_constants + + WATCHMAN_CHECKS = watchman_constants.DEFAULT_CHECKS + ('module.path.to.callable', ) + + Checks take no arguments, and must return a ``dict`` whose keys are applied to the JSON response. Use the ``watchman.decorators.check`` decorator to capture exceptions:: from watchman.decorators import check diff --git a/watchman/constants.py b/watchman/constants.py new file mode 100644 index 0000000..8cd5f95 --- /dev/null +++ b/watchman/constants.py @@ -0,0 +1,9 @@ +DEFAULT_CHECKS = ( + 'watchman.checks.caches', + 'watchman.checks.databases', + 'watchman.checks.storage', +) + +PAID_CHECKS = ( + 'watchman.checks.email', +) diff --git a/watchman/settings.py b/watchman/settings.py index 576e7df..b249942 100644 --- a/watchman/settings.py +++ b/watchman/settings.py @@ -1,4 +1,5 @@ from django.conf import settings +from watchman.constants import DEFAULT_CHECKS, PAID_CHECKS # TODO: these should not be module level (https://github.com/mwarkentin/django-watchman/issues/13) WATCHMAN_ENABLE_PAID_CHECKS = getattr(settings, 'WATCHMAN_ENABLE_PAID_CHECKS', False) @@ -17,15 +18,6 @@ WATCHMAN_DISABLE_APM = getattr(settings, 'WATCHMAN_DISABLE_APM', False) -DEFAULT_CHECKS = ( - 'watchman.checks.caches', - 'watchman.checks.databases', - 'watchman.checks.storage', -) -PAID_CHECKS = ( - 'watchman.checks.email', -) - if WATCHMAN_ENABLE_PAID_CHECKS: DEFAULT_CHECKS = DEFAULT_CHECKS + PAID_CHECKS