-
Notifications
You must be signed in to change notification settings - Fork 62
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
First pass at allowing custom checkers. #12
Conversation
Hi @kezabelle , just wanted to say thanks for submitting this. I'm hoping to be able to review later today. |
@@ -1,5 +1,9 @@ | |||
from django.conf import settings | |||
|
|||
|
|||
# TODO: these should not be module level. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain what you mean here? Maybe open a separate issue for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha, that was a note to myself precisely to open it as a separate issue later, and wasn't intended to be committed as is.
The side-effect of doing it this way (and I'm guilty of it myself; a lot) is that it is cached at the module-level. It mostly isn't a problem for the app as-is because the biggest use-case it may break is override_settings
, which isn't being used.
There was a ticket about documenting a specific way, but no resolution came of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created #13 to track this.
…ecking databases and caches Implements mwarkentin#3
Changes Unknown when pulling 9b7c065 on kezabelle:feature/settings_checkers into * on mwarkentin:master*. |
Finally found time to do the work discussed in previous comments. |
Great! I'll try to take a look this afternoon. On Friday, May 30, 2014, Keryn Knight [email protected] wrote:
|
@kezabelle Sorry about the delay. 😦 I've checked out your branch locally, and done some manual testing. I ran into an issue when attempting to customize the checks that were being run. Not sure what's causing it, but when I try to only run the settings.py WATCHMAN_CHECKS = (
'watchman.checks.caches_status',
) GET https://my.wave-local.com/watchman/ {"databases": [{"default": {"ok": true}}]} Other than that, restricting the checks via query params seemed to work well. Going to experiment with writing a custom check in a separate module and play around with that for a while. If we can fix the issue with the default checks I mentioned above, I think it's just a matter of updating the documentation, and then I'm happy to put out a Thanks again! |
I haven't been able to figure out what's going on with that error - almost seems like something is being cached for some reason. |
return attr | ||
|
||
|
||
def get_checkers(paths_to_checkers): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to get_checks
/ paths_to_checks
.
@kezabelle I've created a separate PR (#15) on a branch of my own to make the changes I suggested - hope you don't mind! I'm not sure if this is the normal way for me to tweak your changes. |
Hey, that's absolutely fine. The trouble with GitHub is it's not possible (AFAIK) to return a notification to unread-status for dealing with later, and I evidently forgot about it as I wasn't immediately able to look at it. I'm sorry about that. Did you manage to establish what was wrong that was causing a cache-like response? |
@kezabelle Haven't been able to track that down yet. |
It's the strangest thing - only seems to be caching if I have both lines in the settings, and comment / uncomment them out to switch. If I have a single setting, which I manually change between them - it will update correctly. I guess if I'm just adding and removing a single Any guesses? In any case, I'm not sure this is actually an issue with the watchman code.. |
Basically, switching between these won't update: WATCHMAN_CHECKS = (
# 'watchman.checks.caches_status',
'watchman.checks.databases_status',
) WATCHMAN_CHECKS = (
'watchman.checks.caches_status',
# 'watchman.checks.databases_status',
) But this will: WATCHMAN_CHECKS = (
'watchman.checks.caches_status',
) WATCHMAN_CHECKS = (
'watchman.checks.databases_status',
) |
Also confirmed that commenting one out, and the other in, and adding a space to the commented out one causes a correct reload. So weird. |
I've made a small video showing the issue: https://s3.amazonaws.com/snaps.michaelwarkentin.com/settings-weirdness.mp4 |
This is taken care of by #15. |
That's an interesting quirk. I couldn't begin to tell you why that's happening, but I'll try and remember to look into it and/or look out for it. |
Would fulfil #3
Should, in theory, support Django 1.4.2 (introduced the vendored
six
library) through to 1.7+Usage in settings is:
Checks now have the same contract as context processors: they consume a
request
and return adict
whose keys are applied to the JSON response:In the absence of any checkers, a 404 is thrown, which is then handled by the
json_view
decorator.Only a subset of checks may be run, by passing
only_check=module.path.to.callable&only_check=...
in the request URL. Only the callables given in querystring, which are in theWATCHMAN_CHECKERS
should be run, eg: