django-watchman icon indicating copy to clipboard operation
django-watchman copied to clipboard

@check decorator breaks response without being wrapped

Open mwarkentin opened this issue 3 years ago • 3 comments

Is your feature request related to a problem? Please describe. @check decorator only works when the check is wrapped by another function which provides the basic response dict ({"check": _decorated_func()}). It would be nice if @check supported being the top-level check function.

Describe the solution you'd like I'd like to be able to define a custom check like this:

@check
def db_write_health_check():
    raise Exception()

This decorator is used by the checks which watchman provides as well, so it will need to handle multiple cases:

  • A "single" check like email and storage
  • A "list" of checks like databases and caches
  • Custom checks

The response structure of existing checks should not change (eg. databases should not be renamed to check_databases or similar).

Describe alternatives you've considered

Documentation and examples:

  • #189
  • #190

Additional context

  • Example of what happens without a wrapper in #188

mwarkentin avatar Nov 25 '22 15:11 mwarkentin

I think what you want is here: https://github.com/mwarkentin/django-watchman/issues/77#issuecomment-215179580

tisdall avatar Nov 29 '22 14:11 tisdall

Thanks.. to 7 years ago you. 😳

mwarkentin avatar Nov 29 '22 15:11 mwarkentin

@kiarashazarnia if this is something you want to work on there might be something to build off of in the comment above. :)

mwarkentin avatar Nov 29 '22 20:11 mwarkentin