Skip to content

Commit

Permalink
feat: connect to redis sentinel for redis queue
Browse files Browse the repository at this point in the history
  • Loading branch information
revant committed Mar 18, 2024
1 parent 0a81407 commit e9ece3b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions frappe/utils/redis_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ def add_user(self, username, password=None):

@classmethod
def get_connection(cls, username=None, password=None):
if frappe.conf.redis_queue_sentinel_enabled:
from frappe.utils.redis_wrapper import get_sentinel_connection

sentinels = [tuple(node.split(":")) for node in frappe.conf.get("redis_queue_sentinels", [])]
sentinel = get_sentinel_connection(
sentinels=sentinels,
sentinel_username=frappe.conf.get("redis_queue_sentinel_username"),
sentinel_password=frappe.conf.get("redis_queue_sentinel_password"),
master_username=frappe.conf.get("redis_queue_master_username", username),
master_password=frappe.conf.get("redis_queue_master_password", password),
)
conn = sentinel.master_for(frappe.conf.get("redis_queue_master_service"))
conn.ping()
return conn
conn = redis.from_url(frappe.conf.redis_queue, username=username, password=password)
conn.ping()
return conn
Expand Down

0 comments on commit e9ece3b

Please sign in to comment.