Skip to content

Commit d7b9e03

Browse files
authored
Merge branch 'master' into master
2 parents 1349de3 + 28a3c97 commit d7b9e03

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

.github/workflows/spellcheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
- name: Checkout
99
uses: actions/checkout@v4
1010
- name: Check Spelling
11-
uses: rojopolis/spellcheck-github-actions@0.48.0
11+
uses: rojopolis/spellcheck-github-actions@0.49.0
1212
with:
1313
config_path: .github/spellcheck-settings.yml
1414
task_name: Markdown

options.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ func (opt *Options) init() {
178178
opt.Network = "tcp"
179179
}
180180
}
181+
if opt.Protocol < 2 {
182+
opt.Protocol = 3
183+
}
181184
if opt.DialTimeout == 0 {
182185
opt.DialTimeout = 5 * time.Second
183186
}

options_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,26 @@ func TestReadTimeoutOptions(t *testing.T) {
222222
}
223223
}
224224
}
225+
226+
func TestProtocolOptions(t *testing.T) {
227+
testCasesMap := map[int]int{
228+
0: 3,
229+
1: 3,
230+
2: 2,
231+
3: 3,
232+
}
233+
234+
o := &Options{}
235+
o.init()
236+
if o.Protocol != 3 {
237+
t.Errorf("got %d instead of %d as protocol option", o.Protocol, 3)
238+
}
239+
240+
for set, want := range testCasesMap {
241+
o := &Options{Protocol: set}
242+
o.init()
243+
if o.Protocol != want {
244+
t.Errorf("got %d instead of %d as protocol option", o.Protocol, want)
245+
}
246+
}
247+
}

redis.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -302,15 +302,9 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
302302
conn := newConn(c.opt, connPool)
303303

304304
var auth bool
305-
protocol := c.opt.Protocol
306-
// By default, use RESP3 in current version.
307-
if protocol < 2 {
308-
protocol = 3
309-
}
310-
311305
// for redis-server versions that do not support the HELLO command,
312306
// RESP2 will continue to be used.
313-
if err = conn.Hello(ctx, protocol, username, password, c.opt.ClientName).Err(); err == nil {
307+
if err = conn.Hello(ctx, c.opt.Protocol, username, password, c.opt.ClientName).Err(); err == nil {
314308
auth = true
315309
} else if !isRedisError(err) {
316310
// When the server responds with the RESP protocol and the result is not a normal

0 commit comments

Comments
 (0)