[GH-ISSUE #320] [FEATURE REQUEST] Add func NewServerWithClient() and NewWithClient()? #1151

Closed
opened 2026-03-07 22:06:31 +03:00 by kerem · 4 comments
Owner

Originally created by @ryan961 on GitHub (Aug 31, 2021).
Original GitHub issue: https://github.com/hibiken/asynq/issues/320

Originally assigned to: @hibiken on GitHub.

// NewWithClient returns a new Client instance given a redis connection option 
// with given `redis.UniversalClient`.
func NewWithClient(cli redis.UniversalClient) *Client {
	return &Client{
		opts: make(map[string][]Option),
		rdb:  rdb.NewRDB(cli),
	}
}

// NewServerWithClient returns a new Server with given `redis.UniversalClient`
// and server configuration.
func NewServerWithClient(cli redis.UniversalClient, cfg Config) *Server {...}
Originally created by @ryan961 on GitHub (Aug 31, 2021). Original GitHub issue: https://github.com/hibiken/asynq/issues/320 Originally assigned to: @hibiken on GitHub. ``` // NewWithClient returns a new Client instance given a redis connection option // with given `redis.UniversalClient`. func NewWithClient(cli redis.UniversalClient) *Client { return &Client{ opts: make(map[string][]Option), rdb: rdb.NewRDB(cli), } } ``` ``` // NewServerWithClient returns a new Server with given `redis.UniversalClient` // and server configuration. func NewServerWithClient(cli redis.UniversalClient, cfg Config) *Server {...} ```
kerem 2026-03-07 22:06:31 +03:00
Author
Owner

@hibiken commented on GitHub (Aug 31, 2021):

@Ryalu thank you for opening a feature request.

I intentionally didn't add this option because I don't want asynq package API to be dependent on a specific go-redis/redis package API. For example, if the NewClient function takes github.com/go-redis/redis/v7.UniversalClient then we would need to bump our major version if we want to update to github.com/go-redis/redis/v8.UniversalClient. Or we could potentially use other redis client library and I don't want to make a major version bump because of that.
In short, I believe the fact that we are using go-redis/redis package is an internal implementation detail that shouldn't be exposed in our API.

Why do you want this as a feature? Is our RedisConnOpt missing some field to tune redis client behavior? If so, we can consider adding more options there.

<!-- gh-comment-id:908844102 --> @hibiken commented on GitHub (Aug 31, 2021): @Ryalu thank you for opening a feature request. I intentionally didn't add this option because I don't want `asynq` package API to be dependent on a specific `go-redis/redis` package API. For example, if the `NewClient` function takes `github.com/go-redis/redis/v7.UniversalClient` then we would need to bump our major version if we want to update to `github.com/go-redis/redis/v8.UniversalClient`. Or we could potentially use other redis client library and I don't want to make a major version bump because of that. In short, I believe the fact that we are using `go-redis/redis` package is an internal implementation detail that shouldn't be exposed in our API. Why do you want this as a feature? Is our `RedisConnOpt` missing some field to tune redis client behavior? If so, we can consider adding more options there.
Author
Owner

@ryan961 commented on GitHub (Aug 31, 2021):

@Ryalu thank you for opening a feature request.

I intentionally didn't add this option because I don't want asynq package API to be dependent on a specific go-redis/redis package API. For example, if the NewClient function takes github.com/go-redis/redis/v7.UniversalClient then we would need to bump our major version if we want to update to github.com/go-redis/redis/v8.UniversalClient. Or we could potentially use other redis client library and I don't want to make a major version bump because of that.
In short, I believe the fact that we are using go-redis/redis package is an internal implementation detail that shouldn't be exposed in our API.

Why do you want this as a feature? Is our RedisConnOpt missing some field to tune redis client behavior? If so, we can consider adding more options there.

Thanks for replying, I know, I just want to unify my configuration file. 👍

<!-- gh-comment-id:909035695 --> @ryan961 commented on GitHub (Aug 31, 2021): > @Ryalu thank you for opening a feature request. > > I intentionally didn't add this option because I don't want `asynq` package API to be dependent on a specific `go-redis/redis` package API. For example, if the `NewClient` function takes `github.com/go-redis/redis/v7.UniversalClient` then we would need to bump our major version if we want to update to `github.com/go-redis/redis/v8.UniversalClient`. Or we could potentially use other redis client library and I don't want to make a major version bump because of that. > In short, I believe the fact that we are using `go-redis/redis` package is an internal implementation detail that shouldn't be exposed in our API. > > Why do you want this as a feature? Is our `RedisConnOpt` missing some field to tune redis client behavior? If so, we can consider adding more options there. Thanks for replying, I know, I just want to unify my configuration file. 👍
Author
Owner

@hibiken commented on GitHub (Aug 31, 2021):

@Ryalu As discussed in #321 , you could implement your own type that satisfies asynq.RedisConnOpt interface so that you have full control/access over the redis client.

Let me know if that works!

<!-- gh-comment-id:909230302 --> @hibiken commented on GitHub (Aug 31, 2021): @Ryalu As discussed in #321 , you could implement your own type that satisfies `asynq.RedisConnOpt` interface so that you have full control/access over the redis client. Let me know if that works!
Author
Owner

@hibiken commented on GitHub (Sep 7, 2021):

Closing this; @Ryalu feel free to reopen if you have any follow up questions!

<!-- gh-comment-id:914336459 --> @hibiken commented on GitHub (Sep 7, 2021): Closing this; @Ryalu feel free to reopen if you have any follow up questions!
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#1151
No description provided.