File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -340,6 +340,7 @@ type clusterNode struct {
340
340
latency uint32 // atomic
341
341
generation uint32 // atomic
342
342
failing uint32 // atomic
343
+ loaded uint32 // atomic
343
344
344
345
// last time the latency measurement was performed for the node, stored in nanoseconds
345
346
// from epoch
@@ -406,6 +407,7 @@ func (n *clusterNode) Latency() time.Duration {
406
407
407
408
func (n * clusterNode ) MarkAsFailing () {
408
409
atomic .StoreUint32 (& n .failing , uint32 (time .Now ().Unix ()))
410
+ atomic .StoreUint32 (& n .loaded , 0 )
409
411
}
410
412
411
413
func (n * clusterNode ) Failing () bool {
@@ -449,11 +451,21 @@ func (n *clusterNode) SetLastLatencyMeasurement(t time.Time) {
449
451
}
450
452
451
453
func (n * clusterNode ) Loading () bool {
454
+ loaded := atomic .LoadUint32 (& n .loaded )
455
+ if loaded == 1 {
456
+ return false
457
+ }
458
+
459
+ // check if the node is loading
452
460
ctx , cancel := context .WithTimeout (context .Background (), 100 * time .Millisecond )
453
461
defer cancel ()
454
462
455
463
err := n .Client .Ping (ctx ).Err ()
456
- return err != nil && isLoadingError (err )
464
+ loading := err != nil && isLoadingError (err )
465
+ if ! loading {
466
+ atomic .StoreUint32 (& n .loaded , 1 )
467
+ }
468
+ return loading
457
469
}
458
470
459
471
//------------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments