@@ -6,24 +6,24 @@ import (
6
6
"github.com/tarantool/go-tarantool/v2"
7
7
)
8
8
9
- type RoundRobinStrategy struct {
9
+ type roundRobinStrategy struct {
10
10
conns []* tarantool.Connection
11
11
indexByAddr map [string ]uint
12
12
mutex sync.RWMutex
13
13
size uint
14
14
current uint
15
15
}
16
16
17
- func NewEmptyRoundRobin (size int ) * RoundRobinStrategy {
18
- return & RoundRobinStrategy {
17
+ func newRoundRobinStrategy (size int ) * roundRobinStrategy {
18
+ return & roundRobinStrategy {
19
19
conns : make ([]* tarantool.Connection , 0 , size ),
20
20
indexByAddr : make (map [string ]uint ),
21
21
size : 0 ,
22
22
current : 0 ,
23
23
}
24
24
}
25
25
26
- func (r * RoundRobinStrategy ) GetConnByAddr (addr string ) * tarantool.Connection {
26
+ func (r * roundRobinStrategy ) GetConnByAddr (addr string ) * tarantool.Connection {
27
27
r .mutex .RLock ()
28
28
defer r .mutex .RUnlock ()
29
29
@@ -35,7 +35,7 @@ func (r *RoundRobinStrategy) GetConnByAddr(addr string) *tarantool.Connection {
35
35
return r .conns [index ]
36
36
}
37
37
38
- func (r * RoundRobinStrategy ) DeleteConnByAddr (addr string ) * tarantool.Connection {
38
+ func (r * roundRobinStrategy ) DeleteConnByAddr (addr string ) * tarantool.Connection {
39
39
r .mutex .Lock ()
40
40
defer r .mutex .Unlock ()
41
41
@@ -63,14 +63,14 @@ func (r *RoundRobinStrategy) DeleteConnByAddr(addr string) *tarantool.Connection
63
63
return conn
64
64
}
65
65
66
- func (r * RoundRobinStrategy ) IsEmpty () bool {
66
+ func (r * roundRobinStrategy ) IsEmpty () bool {
67
67
r .mutex .RLock ()
68
68
defer r .mutex .RUnlock ()
69
69
70
70
return r .size == 0
71
71
}
72
72
73
- func (r * RoundRobinStrategy ) GetNextConnection () * tarantool.Connection {
73
+ func (r * roundRobinStrategy ) GetNextConnection () * tarantool.Connection {
74
74
r .mutex .RLock ()
75
75
defer r .mutex .RUnlock ()
76
76
@@ -80,7 +80,7 @@ func (r *RoundRobinStrategy) GetNextConnection() *tarantool.Connection {
80
80
return r .conns [r .nextIndex ()]
81
81
}
82
82
83
- func (r * RoundRobinStrategy ) GetConnections () []* tarantool.Connection {
83
+ func (r * roundRobinStrategy ) GetConnections () []* tarantool.Connection {
84
84
r .mutex .RLock ()
85
85
defer r .mutex .RUnlock ()
86
86
@@ -90,7 +90,7 @@ func (r *RoundRobinStrategy) GetConnections() []*tarantool.Connection {
90
90
return ret
91
91
}
92
92
93
- func (r * RoundRobinStrategy ) AddConn (addr string , conn * tarantool.Connection ) {
93
+ func (r * roundRobinStrategy ) AddConn (addr string , conn * tarantool.Connection ) {
94
94
r .mutex .Lock ()
95
95
defer r .mutex .Unlock ()
96
96
@@ -103,7 +103,7 @@ func (r *RoundRobinStrategy) AddConn(addr string, conn *tarantool.Connection) {
103
103
}
104
104
}
105
105
106
- func (r * RoundRobinStrategy ) nextIndex () uint {
106
+ func (r * roundRobinStrategy ) nextIndex () uint {
107
107
ret := r .current % r .size
108
108
r .current ++
109
109
return ret
0 commit comments