MCPcopy
hub / github.com/grafana/dskit / RingCompare

Method RingCompare

ring/model.go:640–709  ·  view source on GitHub ↗

RingCompare compares this ring against another one and returns one of Equal, EqualButStatesAndTimestamps or Different.

(o *Desc)

Source from the content-addressed store, hash-verified

638
639// RingCompare compares this ring against another one and returns one of Equal, EqualButStatesAndTimestamps or Different.
640func (d *Desc) RingCompare(o *Desc) CompareResult {
641 if d == nil {
642 if o == nil || len(o.Ingesters) == 0 {
643 return Equal
644 }
645 return Different
646 }
647 if o == nil {
648 if len(d.Ingesters) == 0 {
649 return Equal
650 }
651 return Different
652 }
653
654 if len(d.Ingesters) != len(o.Ingesters) {
655 return Different
656 }
657
658 equalStatesAndTimestamps := true
659
660 for name, ing := range d.Ingesters {
661 oing, ok := o.Ingesters[name]
662 if !ok {
663 return Different
664 }
665
666 if ing.Addr != oing.Addr {
667 return Different
668 }
669
670 if ing.Zone != oing.Zone {
671 return Different
672 }
673
674 if ing.RegisteredTimestamp != oing.RegisteredTimestamp {
675 return Different
676 }
677
678 if ing.ReadOnly != oing.ReadOnly {
679 return Different
680 }
681
682 if ing.ReadOnlyUpdatedTimestamp != oing.ReadOnlyUpdatedTimestamp {
683 return Different
684 }
685
686 if len(ing.Tokens) != len(oing.Tokens) {
687 return Different
688 }
689
690 for ix, t := range ing.Tokens {
691 if oing.Tokens[ix] != t {
692 return Different
693 }
694 }
695
696 if ing.Timestamp != oing.Timestamp {
697 equalStatesAndTimestamps = false

Callers 3

benchmarkUpdateRingStateFunction · 0.95
updateRingStateMethod · 0.80
TestDesc_RingsCompareFunction · 0.80

Calls

no outgoing calls

Tested by 2

benchmarkUpdateRingStateFunction · 0.76
TestDesc_RingsCompareFunction · 0.64