[PR #953] [CLOSED] Add NewClientWithExistingRedisClient to create a client with an existing Redis connection #1953

Closed
opened 2026-03-07 22:14:02 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hibiken/asynq/pull/953
Author: @sanudatta11
Created: 10/31/2024
Status: Closed

Base: masterHead: feature/use-redis-connection


📝 Commits (1)

  • 58b2c2c Added Code for reusing Redis Connection

📊 Changes

2 files changed (+35 additions, -0 deletions)

View changed files

📝 client.go (+10 -0)
📝 client_test.go (+25 -0)

📄 Description

PR Description

This PR introduces a new function NewClientWithExistingRedisClient to the Client struct. This function allows the creation of a Client instance using an already established redis.UniversalClient.

Changes:

  • Added NewClientWithExistingRedisClient function.

  • New Function Pings the provided Redis client to ensure connectivity.

  • Creates a new Client instance using the existing Redis client.

  • Sets the sharedConnection flag to false to indicate that the connection should not be closed by the Client.

This enhancement is useful for scenarios where the Redis connection is managed externally and should not be closed by the Client.

I personally had a project usecase where I didn't want to pass the username password as I wanted to reuse the existing redis client and thus made this addtion.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hibiken/asynq/pull/953 **Author:** [@sanudatta11](https://github.com/sanudatta11) **Created:** 10/31/2024 **Status:** ❌ Closed **Base:** `master` ← **Head:** `feature/use-redis-connection` --- ### 📝 Commits (1) - [`58b2c2c`](https://github.com/hibiken/asynq/commit/58b2c2c6c5b25e2c76dd934e4f06f74145f2a85c) Added Code for reusing Redis Connection ### 📊 Changes **2 files changed** (+35 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `client.go` (+10 -0) 📝 `client_test.go` (+25 -0) </details> ### 📄 Description **PR Description** This PR introduces a new function NewClientWithExistingRedisClient to the Client struct. This function allows the creation of a Client instance using an already established redis.UniversalClient. **Changes:** - Added NewClientWithExistingRedisClient function. - New Function Pings the provided Redis client to ensure connectivity. - Creates a new Client instance using the existing Redis client. - Sets the sharedConnection flag to false to indicate that the connection should not be closed by the Client. This enhancement is useful for scenarios where the Redis connection is managed externally and should not be closed by the Client. I personally had a project usecase where I didn't want to pass the username password as I wanted to reuse the existing redis client and thus made this addtion. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-07 22:14:02 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asynq#1953
No description provided.