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 @@ -349,6 +349,7 @@ type clusterNode struct {
349
349
latency uint32 // atomic
350
350
generation uint32 // atomic
351
351
failing uint32 // atomic
352
+ loaded uint32 // atomic
352
353
353
354
// last time the latency measurement was performed for the node, stored in nanoseconds
354
355
// from epoch
@@ -415,6 +416,7 @@ func (n *clusterNode) Latency() time.Duration {
415
416
416
417
func (n * clusterNode ) MarkAsFailing () {
417
418
atomic .StoreUint32 (& n .failing , uint32 (time .Now ().Unix ()))
419
+ atomic .StoreUint32 (& n .loaded , 0 )
418
420
}
419
421
420
422
func (n * clusterNode ) Failing () bool {
@@ -458,11 +460,21 @@ func (n *clusterNode) SetLastLatencyMeasurement(t time.Time) {
458
460
}
459
461
460
462
func (n * clusterNode ) Loading () bool {
463
+ loaded := atomic .LoadUint32 (& n .loaded )
464
+ if loaded == 1 {
465
+ return false
466
+ }
467
+
468
+ // check if the node is loading
461
469
ctx , cancel := context .WithTimeout (context .Background (), 100 * time .Millisecond )
462
470
defer cancel ()
463
471
464
472
err := n .Client .Ping (ctx ).Err ()
465
- return err != nil && isLoadingError (err )
473
+ loading := err != nil && isLoadingError (err )
474
+ if ! loading {
475
+ atomic .StoreUint32 (& n .loaded , 1 )
476
+ }
477
+ return loading
466
478
}
467
479
468
480
//------------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments