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 {
349349 latency uint32 // atomic
350350 generation uint32 // atomic
351351 failing uint32 // atomic
352+ loaded uint32 // atomic
352353
353354 // last time the latency measurement was performed for the node, stored in nanoseconds
354355 // from epoch
@@ -415,6 +416,7 @@ func (n *clusterNode) Latency() time.Duration {
415416
416417func (n * clusterNode ) MarkAsFailing () {
417418 atomic .StoreUint32 (& n .failing , uint32 (time .Now ().Unix ()))
419+ atomic .StoreUint32 (& n .loaded , 0 )
418420}
419421
420422func (n * clusterNode ) Failing () bool {
@@ -458,11 +460,21 @@ func (n *clusterNode) SetLastLatencyMeasurement(t time.Time) {
458460}
459461
460462func (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
461469 ctx , cancel := context .WithTimeout (context .Background (), 100 * time .Millisecond )
462470 defer cancel ()
463471
464472 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
466478}
467479
468480//------------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments