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 {
340340 latency uint32 // atomic
341341 generation uint32 // atomic
342342 failing uint32 // atomic
343+ loaded uint32 // atomic
343344
344345 // last time the latency measurement was performed for the node, stored in nanoseconds
345346 // from epoch
@@ -406,6 +407,7 @@ func (n *clusterNode) Latency() time.Duration {
406407
407408func (n * clusterNode ) MarkAsFailing () {
408409 atomic .StoreUint32 (& n .failing , uint32 (time .Now ().Unix ()))
410+ atomic .StoreUint32 (& n .loaded , 0 )
409411}
410412
411413func (n * clusterNode ) Failing () bool {
@@ -449,11 +451,21 @@ func (n *clusterNode) SetLastLatencyMeasurement(t time.Time) {
449451}
450452
451453func (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
452460 ctx , cancel := context .WithTimeout (context .Background (), 100 * time .Millisecond )
453461 defer cancel ()
454462
455463 err := n .Client .Ping (ctx ).Err ()
456- return err != nil && isLoadingError (err )
464+ loading := err != nil && isLoadingError (err )
465+ if loading == false {
466+ atomic .StoreUint32 (& n .loaded , 1 )
467+ }
468+ return loading
457469}
458470
459471//------------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments