From 840c25cb6f320501886a82a5e75f47b491e46fbe Mon Sep 17 00:00:00 2001 From: ljun20160606 Date: Thu, 18 May 2023 21:29:58 +0800 Subject: [PATCH] feat: add field protocol to setupClusterQueryParams (#2600) --- cluster.go | 1 + cluster_test.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/cluster.go b/cluster.go index d20295c7d..941838dd0 100644 --- a/cluster.go +++ b/cluster.go @@ -217,6 +217,7 @@ func setupClusterConn(u *url.URL, host string, o *ClusterOptions) (*ClusterOptio func setupClusterQueryParams(u *url.URL, o *ClusterOptions) (*ClusterOptions, error) { q := queryOptions{q: u.Query()} + o.Protocol = q.int("protocol") o.ClientName = q.string("client_name") o.MaxRedirects = q.int("max_redirects") o.ReadOnly = q.bool("read_only") diff --git a/cluster_test.go b/cluster_test.go index 75ea40df1..d3b4474a2 100644 --- a/cluster_test.go +++ b/cluster_test.go @@ -1519,6 +1519,10 @@ var _ = Describe("ClusterClient ParseURL", func() { test: "UseDefault", url: "redis://localhost:123?conn_max_idle_time=", o: &redis.ClusterOptions{Addrs: []string{"localhost:123"}, ConnMaxIdleTime: 0}, + }, { + test: "Protocol", + url: "redis://localhost:123?protocol=2", + o: &redis.ClusterOptions{Addrs: []string{"localhost:123"}, Protocol: 2}, }, { test: "ClientName", url: "redis://localhost:123?client_name=cluster_hi",