Skip to content

Commit 5450d43

Browse files
committed
fix roundRobin and randomChoice Create()
1 parent 06ab434 commit 5450d43

File tree

2 files changed

+4
-19
lines changed

2 files changed

+4
-19
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
* Removed `CustomOption` and taking client with custom options
44
* Removed `proxy` package
55
* Improved `db.With()` helper for child connections creation
6-
* Set shared `conn.Pool` for all children `ydb.Connection`
6+
* Set shared `conn.Pool` for all children `ydb.Connection`
7+
* Fixed bug with `RoundRobin` and `RandomChoice` balancers `Create()`
78

89
## 3.12.1
910
* Added `trace.Driver.OnConnPark` event

internal/balancer/rr/rr.go

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,7 @@ type roundRobin struct {
2828
}
2929

3030
func (r *roundRobin) Create() balancer.Balancer {
31-
return &roundRobin{
32-
min: r.min,
33-
max: r.max,
34-
belt: r.belt,
35-
next: r.next,
36-
conns: r.conns,
37-
r: rand.New(),
38-
}
31+
return RoundRobin()
3932
}
4033

4134
func RoundRobin() balancer.Balancer {
@@ -58,16 +51,7 @@ type randomChoice struct {
5851
}
5952

6053
func (r *randomChoice) Create() balancer.Balancer {
61-
return &randomChoice{
62-
roundRobin: roundRobin{
63-
min: r.roundRobin.min,
64-
max: r.roundRobin.max,
65-
belt: r.roundRobin.belt,
66-
next: r.roundRobin.next,
67-
conns: r.roundRobin.conns,
68-
r: rand.New(),
69-
},
70-
}
54+
return RandomChoice()
7155
}
7256

7357
func (r *roundRobin) Next() conn.Conn {

0 commit comments

Comments
 (0)