File tree 2 files changed +11
-16
lines changed
2 files changed +11
-16
lines changed Original file line number Diff line number Diff line change @@ -117,7 +117,10 @@ func (r *IngesterRegistration) Unregister() {
117
117
118
118
func (r * IngesterRegistration ) loop () {
119
119
defer r .wait .Done ()
120
- tokens := r .pickTokens ()
120
+ tokens , err := r .pickTokens ()
121
+ if err != nil {
122
+ log .Fatalf ("Failed to pick tokens in consul: %v" , err )
123
+ }
121
124
122
125
if ! r .skipUnregister {
123
126
defer r .unregister ()
@@ -126,7 +129,7 @@ func (r *IngesterRegistration) loop() {
126
129
r .heartbeat (tokens )
127
130
}
128
131
129
- func (r * IngesterRegistration ) pickTokens () []uint32 {
132
+ func (r * IngesterRegistration ) pickTokens () ( []uint32 , error ) {
130
133
var tokens []uint32
131
134
pickTokens := func (in interface {}) (out interface {}, retry bool , err error ) {
132
135
var ringDesc * Desc
@@ -158,11 +161,10 @@ func (r *IngesterRegistration) pickTokens() []uint32 {
158
161
return ringDesc , true , nil
159
162
}
160
163
if err := r .consul .CAS (consulKey , descFactory , pickTokens ); err != nil {
161
- log .Fatalf ("Failed to pick tokens in consul: %v" , err )
162
- return nil
164
+ return nil , err
163
165
}
164
166
log .Infof ("Ingester added to consul" )
165
- return tokens
167
+ return tokens , nil
166
168
}
167
169
168
170
func (r * IngesterRegistration ) heartbeat (tokens []uint32 ) {
Original file line number Diff line number Diff line change @@ -25,17 +25,10 @@ func newMockConsulClient() ConsulClient {
25
25
}
26
26
27
27
func copyKVPair (in * consul.KVPair ) * consul.KVPair {
28
- value := make ([]byte , len (in .Value ))
29
- copy (value , in .Value )
30
- return & consul.KVPair {
31
- Key : in .Key ,
32
- CreateIndex : in .CreateIndex ,
33
- ModifyIndex : in .ModifyIndex ,
34
- LockIndex : in .LockIndex ,
35
- Flags : in .Flags ,
36
- Value : value ,
37
- Session : in .Session ,
38
- }
28
+ out := * in
29
+ out .Value = make ([]byte , len (in .Value ))
30
+ copy (out .Value , in .Value )
31
+ return & out
39
32
}
40
33
41
34
// periodic loop to wake people up, so they can honour timeouts
You can’t perform that action at this time.
0 commit comments