Skip to content

Commit

Permalink
feat(url): Add valkey and valkeys schemes (#21)
Browse files Browse the repository at this point in the history
Inspired by the valkey-py client.

https://github.com/valkey-io/valkey-py/blob/v6.0.2/valkey/_parsers/url_parser.py#L40

Signed-off-by: Julien Riou <julien@riou.xyz>
  • Loading branch information
jouir authored Dec 29, 2024
1 parent 784282a commit c4248d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions url.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ func ParseURL(str string) (opt ClientOption, err error) {
return dialer.Dial("unix", s)
}
opt.InitAddress = []string{strings.TrimSpace(u.Path)}
case "rediss":
case "rediss", "valkeys":
opt.TLSConfig = &tls.Config{
MinVersion: tls.VersionTLS12,
}
case "redis":
case "redis", "valkey":
default:
return opt, fmt.Errorf("valkey: invalid URL scheme: %s", u.Scheme)
}
Expand Down
6 changes: 6 additions & 0 deletions url_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ func TestParseURL(t *testing.T) {
if opt, err := ParseURL("rediss://"); err != nil || opt.TLSConfig == nil {
t.Fatalf("unexpected %v %v", opt, err)
}
if opt, err := ParseURL("valkeys://"); err != nil || opt.TLSConfig == nil {
t.Fatalf("unexpected %v %v", opt, err)
}
if opt, err := ParseURL("unix://"); err != nil || opt.DialFn == nil {
t.Fatalf("unexpected %v %v", opt, err)
}
if opt, err := ParseURL("valkey://"); err != nil {
t.Fatalf("unexpected %v %v", opt, err)
}
if opt, err := ParseURL("redis://"); err != nil || opt.InitAddress[0] != "localhost:6379" {
t.Fatalf("unexpected %v %v", opt, err)
}
Expand Down

0 comments on commit c4248d4

Please sign in to comment.