[GH-ISSUE #103] [FEATURE REQUEST] Add a function to create RedisConnOpt from a URL #1041

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

Originally created by @rugwirobaker on GitHub (Mar 5, 2020).
Original GitHub issue: https://github.com/hibiken/asynq/issues/103

I like how unlike most redis backed task queues you have abstracted away connection pooling so I don't have to think about which client to connect with. However I had to write my own redis ParseURL function cause it was bit annoying passing multiple configuration values for just one resource while I pass just one for all the others.

Describe the solution you'd like
Though it's trivial it would be really great to have one provided by the package.
that would be of the following signature:

func ParseRedisURL(url string)(*asynq.RedisClientOpt, error)

Describe alternatives you've considered
I wrote my own.

Additional context

The task is simple enough I could open a PR if you approve

Originally created by @rugwirobaker on GitHub (Mar 5, 2020). Original GitHub issue: https://github.com/hibiken/asynq/issues/103 I like how unlike most `redis` backed `task queues` you have abstracted away connection pooling so I don't have to think about which client to connect with. However I had to write my own `redis ParseURL` function cause it was bit annoying passing multiple configuration values for just one resource while I pass just one for all the others. **Describe the solution you'd like** Though it's trivial it would be really great to have one provided by the package. that would be of the following signature: ``` func ParseRedisURL(url string)(*asynq.RedisClientOpt, error) ``` **Describe alternatives you've considered** I wrote my own. **Additional context** The task is simple enough I could open a PR if you approve
kerem 2026-03-07 22:04:29 +03:00
Author
Owner

@hibiken commented on GitHub (Mar 5, 2020):

@rugwirobaker Thanks for opening this issue!
I think having a function to create a RedisConnOpt from a URL is valuable.

Would you mind explaining the pain points in more detail just so that I understand it better? What was annoying? I'm guessing you had access to a Redis URL and had to parse it every time you need to instantiate asynq.Client or asynq.Background?

For the specification of the function, let's create a function with this signature:

func ParseRedisURL(url string) (RedisConnOpt, error)

Note: RedisConnOpt is a union of RedisClientOpt and RedisFailoverClientOpt. The former is used connecting directly to Redis and the latter is used to connecting to Redis using Sentinel.

For the URL scheme I found this page (let's follow this scheme to support different mode)

I'm excited to get contributions from the community, so please feel free to open a PR!

<!-- gh-comment-id:595257499 --> @hibiken commented on GitHub (Mar 5, 2020): @rugwirobaker Thanks for opening this issue! I think having a function to create a `RedisConnOpt` from a URL is valuable. Would you mind explaining the pain points in more detail just so that I understand it better? What was annoying? I'm guessing you had access to a Redis URL and had to parse it every time you need to instantiate `asynq.Client` or `asynq.Background`? For the specification of the function, let's create a function with this signature: ```go func ParseRedisURL(url string) (RedisConnOpt, error) ``` *Note*: `RedisConnOpt` is a union of `RedisClientOpt` and `RedisFailoverClientOpt`. The former is used connecting directly to Redis and the latter is used to connecting to Redis using Sentinel. For the URL scheme I found this [page](https://github.com/lettuce-io/lettuce-core/wiki/Redis-URI-and-connection-details#uri-syntax) (let's follow this scheme to support different mode) I'm excited to get contributions from the community, so please feel free to open a PR!
Author
Owner

@rugwirobaker commented on GitHub (Mar 9, 2020):

Hey, I have noticed that the redis client you are using already has it's own parser. Wouldn't be a good idea to just use that and build from there?

<!-- gh-comment-id:596413115 --> @rugwirobaker commented on GitHub (Mar 9, 2020): Hey, I have noticed that the redis client you are using already has it's own parser. Wouldn't be a good idea to just use that and build from there?
Author
Owner

@hibiken commented on GitHub (Mar 9, 2020):

I see. Redis#ParseURL returns Options which we can use for RedisClientOpt. But we also want to support RedisFailoverClientOpt which needs FailoverOptions From the redis package. Maybe we could look at their implementations as a reference? And I suppose we could use Redis#ParseURL to handle URLs for basic cases.

<!-- gh-comment-id:596518231 --> @hibiken commented on GitHub (Mar 9, 2020): I see. [Redis#ParseURL](https://godoc.org/github.com/go-redis/redis#ParseURL) returns [Options](https://godoc.org/github.com/go-redis/redis#Options) which we can use for `RedisClientOpt`. But we also want to support `RedisFailoverClientOpt` which needs [FailoverOptions](https://godoc.org/github.com/go-redis/redis#FailoverOptions) From the redis package. Maybe we could look at their implementations as a reference? And I suppose we could use [Redis#ParseURL](https://godoc.org/github.com/go-redis/redis#ParseURL) to handle URLs for basic cases.
Author
Owner

@hibiken commented on GitHub (Mar 15, 2020):

@rugwirobaker I'm assigning this issue to you for now, but feel free to assign it back to me if you don't have enough bandwidth to work on this in the next few weeks 👍

<!-- gh-comment-id:599261714 --> @hibiken commented on GitHub (Mar 15, 2020): @rugwirobaker I'm assigning this issue to you for now, but feel free to assign it back to me if you don't have enough bandwidth to work on this in the next few weeks 👍
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#1041
No description provided.