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 1 commit
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
11 changes: 10 additions & 1 deletion redis/conn.go
Expand Up @@ -320,6 +320,15 @@ var pathDBRegexp = regexp.MustCompile(`/(\d*)\z`)
// URI scheme. URLs should follow the draft IANA specification for the
// scheme (https://www.iana.org/assignments/uri-schemes/prov/redis).
stevenh marked this conversation as resolved.
Show resolved Hide resolved
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 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 +390,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