Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make watchman constants importable Fixes #130 #131

Merged
merged 2 commits into from
Oct 19, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions watchman/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
DEFAULT_CHECKS = (
'watchman.checks.caches',
'watchman.checks.databases',
'watchman.checks.storage',
)
PAID_CHECKS = (
jonespm marked this conversation as resolved.
Show resolved Hide resolved
'watchman.checks.email',
)
10 changes: 1 addition & 9 deletions watchman/settings.py
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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

Expand Down