django-health-check 3.21.1__tar.gz → 3.22.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {django_health_check-3.21.1 → django_health_check-3.22.0}/PKG-INFO +1 -1
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/_version.py +3 -3
- django_health_check-3.22.0/health_check/contrib/redis/backends.py +75 -0
- django_health_check-3.21.1/health_check/contrib/redis/backends.py +0 -50
- {django_health_check-3.21.1 → django_health_check-3.22.0}/LICENSE +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/README.md +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/__init__.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/backends.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/cache/__init__.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/cache/apps.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/cache/backends.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/conf.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/__init__.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/celery/__init__.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/celery/apps.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/celery/backends.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/celery/tasks.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/celery_ping/__init__.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/celery_ping/apps.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/celery_ping/backends.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/db_heartbeat/__init__.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/db_heartbeat/apps.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/db_heartbeat/backends.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/mail/__init__.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/mail/apps.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/mail/backends.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/migrations/__init__.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/migrations/apps.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/migrations/backends.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/psutil/__init__.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/psutil/apps.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/psutil/backends.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/rabbitmq/__init__.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/rabbitmq/apps.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/rabbitmq/backends.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/redis/__init__.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/redis/apps.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/s3boto3_storage/__init__.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/s3boto3_storage/apps.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/s3boto3_storage/backends.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/s3boto_storage/__init__.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/s3boto_storage/apps.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/s3boto_storage/backends.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/db/__init__.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/db/apps.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/db/backends.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/db/migrations/0001_initial.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/db/migrations/0002_alter_testmodel_options.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/db/migrations/__init__.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/db/models.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/deprecation.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/exceptions.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/management/__init__.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/management/commands/__init__.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/management/commands/health_check.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/mixins.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/plugins.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/storage/__init__.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/storage/apps.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/storage/backends.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/templates/health_check/index.html +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/urls.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/views.py +0 -0
- {django_health_check-3.21.1 → django_health_check-3.22.0}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: django-health-check
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.22.0
|
|
4
4
|
Summary: Monitor the health of your Django app and its connected services.
|
|
5
5
|
Keywords: django,postgresql
|
|
6
6
|
Author-email: Kristian Ollegaard <kristian@oellegaard.com>, Johannes Maron <johannes@maron.family>
|
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '3.
|
|
32
|
-
__version_tuple__ = version_tuple = (3,
|
|
31
|
+
__version__ = version = '3.22.0'
|
|
32
|
+
__version_tuple__ = version_tuple = (3, 22, 0)
|
|
33
33
|
|
|
34
|
-
__commit_id__ = commit_id = '
|
|
34
|
+
__commit_id__ = commit_id = 'g12f02362c'
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import dataclasses
|
|
2
|
+
import logging
|
|
3
|
+
import typing
|
|
4
|
+
import warnings
|
|
5
|
+
|
|
6
|
+
from django.conf import settings
|
|
7
|
+
from redis import Redis as RedisClient
|
|
8
|
+
from redis import RedisCluster, exceptions
|
|
9
|
+
|
|
10
|
+
from health_check.backends import HealthCheck
|
|
11
|
+
from health_check.exceptions import ServiceUnavailable
|
|
12
|
+
|
|
13
|
+
logger = logging.getLogger(__name__)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclasses.dataclass
|
|
17
|
+
class RedisHealthCheck(HealthCheck):
|
|
18
|
+
"""
|
|
19
|
+
Check Redis service by pinging a Redis client.
|
|
20
|
+
|
|
21
|
+
This check works with any Redis client that implements the ping() method,
|
|
22
|
+
including standard Redis, Sentinel, and Cluster clients.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
client: A Redis client instance (Redis, Sentinel master, or Cluster).
|
|
26
|
+
If provided, this takes precedence over redis_url.
|
|
27
|
+
|
|
28
|
+
Examples:
|
|
29
|
+
Using a standard Redis client:
|
|
30
|
+
>>> from redis import Redis as RedisClient
|
|
31
|
+
>>> Redis(client=RedisClient(host='localhost', port=6379))
|
|
32
|
+
|
|
33
|
+
Using a Cluster client:
|
|
34
|
+
>>> from redis.cluster import RedisCluster
|
|
35
|
+
>>> Redis(client=RedisCluster(host='localhost', port=7000))
|
|
36
|
+
|
|
37
|
+
Using a Sentinel client:
|
|
38
|
+
>>> from redis.sentinel import Sentinel
|
|
39
|
+
>>> sentinel = Sentinel([('localhost', 26379)])
|
|
40
|
+
>>> Redis(client=sentinel.master_for('mymaster'))
|
|
41
|
+
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
client: RedisClient | RedisCluster = dataclasses.field(default=None, repr=False)
|
|
45
|
+
redis_url: str = dataclasses.field(default=getattr(settings, "REDIS_URL", "redis://localhost/1"), repr=False)
|
|
46
|
+
redis_url_options: dict[str, typing.Any] = dataclasses.field(
|
|
47
|
+
default_factory=lambda: getattr(settings, "HEALTHCHECK_REDIS_URL_OPTIONS", {}), repr=False
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
def __post_init__(self):
|
|
51
|
+
if not self.client:
|
|
52
|
+
print(self.client)
|
|
53
|
+
warnings.warn(
|
|
54
|
+
"The 'redis_url' parameter is deprecated. Please use the 'client' parameter instead.",
|
|
55
|
+
DeprecationWarning,
|
|
56
|
+
stacklevel=2,
|
|
57
|
+
)
|
|
58
|
+
self.client = RedisClient.from_url(self.redis_url, **self.redis_url_options)
|
|
59
|
+
|
|
60
|
+
def check_status(self):
|
|
61
|
+
logger.debug("Pinging Redis client...")
|
|
62
|
+
try:
|
|
63
|
+
self.client.ping()
|
|
64
|
+
except ConnectionRefusedError as e:
|
|
65
|
+
raise ServiceUnavailable("Unable to connect to Redis: Connection was refused.") from e
|
|
66
|
+
except exceptions.TimeoutError as e:
|
|
67
|
+
raise ServiceUnavailable("Unable to connect to Redis: Timeout.") from e
|
|
68
|
+
except exceptions.ConnectionError as e:
|
|
69
|
+
raise ServiceUnavailable("Unable to connect to Redis: Connection Error") from e
|
|
70
|
+
except BaseException as e:
|
|
71
|
+
raise ServiceUnavailable("Unknown error.") from e
|
|
72
|
+
else:
|
|
73
|
+
logger.debug("Connection established. Redis is healthy.")
|
|
74
|
+
finally:
|
|
75
|
+
self.client.close()
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import dataclasses
|
|
2
|
-
import logging
|
|
3
|
-
import typing
|
|
4
|
-
|
|
5
|
-
from django.conf import settings
|
|
6
|
-
from redis import exceptions, from_url
|
|
7
|
-
|
|
8
|
-
from health_check.backends import HealthCheck
|
|
9
|
-
from health_check.exceptions import ServiceUnavailable
|
|
10
|
-
|
|
11
|
-
logger = logging.getLogger(__name__)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@dataclasses.dataclass
|
|
15
|
-
class RedisHealthCheck(HealthCheck):
|
|
16
|
-
"""
|
|
17
|
-
Check Redis service by pinging the redis instance with a redis connection.
|
|
18
|
-
|
|
19
|
-
Args:
|
|
20
|
-
redis_url: The Redis connection URL.
|
|
21
|
-
redis_url_options: Additional options for the Redis connection.
|
|
22
|
-
|
|
23
|
-
"""
|
|
24
|
-
|
|
25
|
-
redis_url: str = dataclasses.field(default=getattr(settings, "REDIS_URL", "redis://localhost/1"), repr=False)
|
|
26
|
-
redis_url_options: dict[str, typing.Any] = dataclasses.field(
|
|
27
|
-
default=getattr(settings, "HEALTHCHECK_REDIS_URL_OPTIONS", None), repr=False
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
def check_status(self):
|
|
31
|
-
logger.debug("Got %s as the redis_url. Connecting to redis...", self.redis_url)
|
|
32
|
-
|
|
33
|
-
logger.debug("Attempting to connect to redis...")
|
|
34
|
-
try:
|
|
35
|
-
# conn is used as a context to release opened resources later
|
|
36
|
-
with from_url(self.redis_url, **(self.redis_url_options or {})) as conn:
|
|
37
|
-
conn.ping() # exceptions may be raised upon ping
|
|
38
|
-
except ConnectionRefusedError as e:
|
|
39
|
-
self.add_error(
|
|
40
|
-
ServiceUnavailable("Unable to connect to Redis: Connection was refused."),
|
|
41
|
-
e,
|
|
42
|
-
)
|
|
43
|
-
except exceptions.TimeoutError as e:
|
|
44
|
-
self.add_error(ServiceUnavailable("Unable to connect to Redis: Timeout."), e)
|
|
45
|
-
except exceptions.ConnectionError as e:
|
|
46
|
-
self.add_error(ServiceUnavailable("Unable to connect to Redis: Connection Error"), e)
|
|
47
|
-
except BaseException as e:
|
|
48
|
-
self.add_error(ServiceUnavailable("Unknown error"), e)
|
|
49
|
-
else:
|
|
50
|
-
logger.debug("Connection established. Redis is healthy.")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/celery/__init__.py
RENAMED
|
File without changes
|
{django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/celery/apps.py
RENAMED
|
File without changes
|
{django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/celery/backends.py
RENAMED
|
File without changes
|
{django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/celery/tasks.py
RENAMED
|
File without changes
|
|
File without changes
|
{django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/celery_ping/apps.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/db_heartbeat/apps.py
RENAMED
|
File without changes
|
|
File without changes
|
{django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/mail/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/mail/backends.py
RENAMED
|
File without changes
|
|
File without changes
|
{django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/migrations/apps.py
RENAMED
|
File without changes
|
|
File without changes
|
{django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/psutil/__init__.py
RENAMED
|
File without changes
|
{django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/psutil/apps.py
RENAMED
|
File without changes
|
{django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/psutil/backends.py
RENAMED
|
File without changes
|
{django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/rabbitmq/__init__.py
RENAMED
|
File without changes
|
{django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/rabbitmq/apps.py
RENAMED
|
File without changes
|
{django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/rabbitmq/backends.py
RENAMED
|
File without changes
|
{django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/redis/__init__.py
RENAMED
|
File without changes
|
{django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/contrib/redis/apps.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/db/migrations/0001_initial.py
RENAMED
|
File without changes
|
|
File without changes
|
{django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/db/migrations/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_health_check-3.21.1 → django_health_check-3.22.0}/health_check/management/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|