djblets.util.views¶
Various utility views.
- cached_javascript_catalog(request: HttpRequest, domain: str = 'djangojs', packages: Sequence[str] = []) HttpResponseBase [source]¶
A cached version of javascript_catalog.
- Parameters:
request (
django.http.HttpRequest
) – The HTTP request.domain (
str
) – The translation domain to use when looking up strings.packages (
list
ofstr
) – The package names to get strings from.
- Returns:
The response to send back to the client.
- Return type:
- class HealthCheckStatus(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
-
A status indicator for health checks.
New in version 4.0.
- __str__() str [source]¶
Return a string representation of the status.
This exists so we can compare a string against an enum. Once we move to StrEnum this can be removed.
- Returns:
The string status.
- Return type:
- __format__(format_spec)¶
Return a formatted version of the string as described by format_spec.
- __new__(value)¶
- __repr__()¶
Return repr(self).
- class HealthCheckResult[source]¶
Bases:
TypedDict
Result structure for health checks.
New in version 4.0.
- checks: Dict[str, HealthCheckStatus]¶
The individual checks that were run.
- status: HealthCheckStatus¶
The overall health status of the server.
- __annotations__ = {'checks': ForwardRef('Dict[str, HealthCheckStatus]', module='djblets.util.views'), 'errors': ForwardRef('Dict[str, str]', module='djblets.util.views'), 'status': ForwardRef('HealthCheckStatus', module='djblets.util.views')}¶
- __optional_keys__ = frozenset({})¶
- __orig_bases__ = (<function TypedDict>,)¶
- __required_keys__ = frozenset({'checks', 'errors', 'status'})¶
- __total__ = True¶
- class HealthCheckView(**kwargs)[source]¶
Bases:
View
A view for health checks.
This will check the status of connected database and cache servers, and report whether everything can be accessed. It will return either HTTP 200 or 503, and the payload will be a JSON blob defined by
HealthCheckResult
.New in version 4.0.
- get(request: HttpRequest, *args, **kwargs) HttpResponseBase [source]¶
Perform a health check.
This will do a health check on whether the database and cache server can be used. If both are accessible, this will return an HTTP 200. If not, this will return HTTP 500.
- Parameters:
request (
django.http.HttpRequest
) – The HTTP request.*args (
tuple
, unused) – Positional arguments, for future expansion.**kwargs (
dict
, unused) – Keyword arguments, for future expansion.
- Returns:
The response to send back to the client.
- Return type:
- __annotations__ = {}¶