Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement DialURLContext(...) #574

Merged
merged 5 commits into from Sep 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions redis/conn.go
Expand Up @@ -316,10 +316,17 @@ func DialContext(ctx context.Context, network, address string, options ...DialOp

var pathDBRegexp = regexp.MustCompile(`/(\d*)\z`)

// DialURL connects to a Redis server at the given URL using the Redis
// DialURL wraps DialURLContext using context.Background.
func DialURL(rawurl string, options ...DialOption) (Conn, error) {
ctx := context.Background()

return DialURLContext(ctx, rawurl, options...)
cameronelliott marked this conversation as resolved.
Show resolved Hide resolved
}

// DialURLContext connects to a Redis server at the given URL using the Redis
// URI scheme. URLs should follow the draft IANA specification for the
// scheme (https://www.iana.org/assignments/uri-schemes/prov/redis).
func DialURL(rawurl string, options ...DialOption) (Conn, error) {
func DialURLContext(ctx context.Context, rawurl string, options ...DialOption) (Conn, error) {
u, err := url.Parse(rawurl)
if err != nil {
return nil, err
Expand Down Expand Up @@ -381,7 +388,7 @@ func DialURL(rawurl string, options ...DialOption) (Conn, error) {

options = append(options, DialUseTLS(u.Scheme == "rediss"))

return Dial("tcp", address, options...)
return DialContext(ctx, "tcp", address, options...)
}

// NewConn returns a new Redigo connection for the given net connection.
Expand Down