diff options
Diffstat (limited to 'pkgs/applications/version-management/sourcehut/patches/redis-socket/core/0001-Fix-Unix-socket-support-in-RedisQueueCollector.patch')
-rw-r--r-- | pkgs/applications/version-management/sourcehut/patches/redis-socket/core/0001-Fix-Unix-socket-support-in-RedisQueueCollector.patch | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/pkgs/applications/version-management/sourcehut/patches/redis-socket/core/0001-Fix-Unix-socket-support-in-RedisQueueCollector.patch b/pkgs/applications/version-management/sourcehut/patches/redis-socket/core/0001-Fix-Unix-socket-support-in-RedisQueueCollector.patch new file mode 100644 index 0000000000000..889331f3e07ff --- /dev/null +++ b/pkgs/applications/version-management/sourcehut/patches/redis-socket/core/0001-Fix-Unix-socket-support-in-RedisQueueCollector.patch @@ -0,0 +1,42 @@ +From 76dd636151735671be74ba9d55f773e190e22827 Mon Sep 17 00:00:00 2001 +From: Julien Moutinho <julm+srht@sourcephile.fr> +Date: Fri, 13 May 2022 22:40:46 +0200 +Subject: [PATCH core.sr.ht] Fix Unix socket support in RedisQueueCollector + +The broker URL is not necessarily in the format expected by Redis.from_url + +Especially, Redis.from_url supports this format for Unix sockets: + unix:///run/redis-sourcehut-metasrht/redis.sock?db=0 +See https://redis-py.readthedocs.io/en/stable/#redis.ConnectionPool.from_url + +Whereas Celery+Kombu support Redis but also other transports +and thus expect another scheme: + redis+socket:///run/redis-sourcehut-metasrht/redis.sock?virtual_host=1 +See https://docs.celeryproject.org/en/stable/userguide/configuration.html#redis-backend-settings +and https://github.com/celery/celery/blob/e5d99801e4b56a02af4a2e183879c767228d2817/celery/backends/redis.py#L299-L352 +and https://github.com/celery/kombu/blob/master/kombu/utils/url.py +--- + srht/metrics.py | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/srht/metrics.py b/srht/metrics.py +index 68caf8e..2df5777 100644 +--- a/srht/metrics.py ++++ b/srht/metrics.py +@@ -1,11 +1,12 @@ + import time ++from celery import Celery + from prometheus_client.metrics_core import GaugeMetricFamily + from redis import Redis, ResponseError + + + class RedisQueueCollector: + def __init__(self, broker, name, documentation, queue_name="celery"): +- self.redis = Redis.from_url(broker) ++ self.redis = Celery("collector", broker=broker).connection_for_read().channel().client + self.queue_name = queue_name + self.name = name + self.documentation = documentation +-- +2.35.1 + |