File tree 2 files changed +15
-7
lines changed
2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ type Jodis struct {
22
22
data []byte
23
23
24
24
client models.Client
25
+ online bool
25
26
closed bool
26
27
27
28
watching bool
@@ -98,6 +99,13 @@ func (j *Jodis) Rewatch() (<-chan struct{}, error) {
98
99
}
99
100
100
101
func (j * Jodis ) Start () {
102
+ j .mu .Lock ()
103
+ defer j .mu .Unlock ()
104
+ if j .online {
105
+ return
106
+ }
107
+ j .online = true
108
+
101
109
go func () {
102
110
var delay = & DelayExp2 {
103
111
Min : 1 , Max : 30 ,
Original file line number Diff line number Diff line change @@ -45,13 +45,13 @@ type Proxy struct {
45
45
46
46
lproxy net.Listener
47
47
ladmin net.Listener
48
- xjodis * Jodis
49
48
50
49
ha struct {
51
50
monitor * redis.Sentinel
52
51
masters map [int ]string
53
52
servers []string
54
53
}
54
+ jodis * Jodis
55
55
}
56
56
57
57
var ErrClosedProxy = errors .New ("use of closed proxy" )
@@ -151,7 +151,7 @@ func (s *Proxy) setup(config *Config) error {
151
151
} else {
152
152
s .model .JodisPath = models .JodisPath (config .ProductName , s .model .Token )
153
153
}
154
- s .xjodis = NewJodis (c , s .model )
154
+ s .jodis = NewJodis (c , s .model )
155
155
}
156
156
157
157
return nil
@@ -168,6 +168,9 @@ func (s *Proxy) Start() error {
168
168
}
169
169
s .online = true
170
170
s .router .Start ()
171
+ if s .jodis != nil {
172
+ s .jodis .Start ()
173
+ }
171
174
return nil
172
175
}
173
176
@@ -180,8 +183,8 @@ func (s *Proxy) Close() error {
180
183
s .closed = true
181
184
close (s .exit .C )
182
185
183
- if s .xjodis != nil {
184
- s .xjodis .Close ()
186
+ if s .jodis != nil {
187
+ s .jodis .Close ()
185
188
}
186
189
if s .ladmin != nil {
187
190
s .ladmin .Close ()
@@ -415,9 +418,6 @@ func (s *Proxy) serveProxy() {
415
418
if d := s .config .BackendPingPeriod .Duration (); d != 0 {
416
419
go s .keepAlive (d )
417
420
}
418
- if s .xjodis != nil {
419
- s .xjodis .Start ()
420
- }
421
421
422
422
select {
423
423
case <- s .exit .C :
You can’t perform that action at this time.
0 commit comments