djblets.util.views¶
Various utility views.
- cached_javascript_catalog(request: HttpRequest, domain: str = 'djangojs', packages: Sequence[str] = []) HttpResponseBase ¶
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, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
-
A status indicator for health checks.
New in version 4.0.
- UP = 'UP'¶
The state when a service is running and can be connected to.
- DOWN = 'DOWN'¶
The state when a service is down or otherwise cannot be connected to.
- UNKNOWN = 'UNKNOWN'¶
The state when it is unknown if a service is up or down.
- __str__() str ¶
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¶
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')}¶
- __closed__ = False¶
- __extra_items__ = None¶
- __mutable_keys__ = frozenset({'checks', 'errors', 'status'})¶
- __optional_keys__ = frozenset({})¶
- __orig_bases__ = (<function TypedDict>,)¶
- __readonly_keys__ = frozenset({})¶
- __required_keys__ = frozenset({'checks', 'errors', 'status'})¶
- __total__ = True¶
- class HealthCheckView(**kwargs)¶
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 ¶
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__ = {}¶