MCPcopy
hub / github.com/grafana/tempo / Merge

Method Merge

pkg/usagestats/seed.go:23–50  ·  view source on GitHub ↗

Merge implements the memberlist.Mergeable interface. It allow to merge the content of two different seeds.

(mergeable memberlist.Mergeable, _ bool)

Source from the content-addressed store, hash-verified

21// Merge implements the memberlist.Mergeable interface.
22// It allow to merge the content of two different seeds.
23func (c *ClusterSeed) Merge(mergeable memberlist.Mergeable, _ bool) (change memberlist.Mergeable, err error) {
24 if mergeable == nil {
25 return nil, nil
26 }
27 other, ok := mergeable.(*ClusterSeed)
28 if !ok {
29 return nil, fmt.Errorf("expected *usagestats.ClusterSeed, got %T", mergeable)
30 }
31 if other == nil {
32 return nil, nil
33 }
34 // if we already have (c) the oldest key, then should not request change.
35 if c.CreatedAt.Before(other.CreatedAt) {
36 return nil, nil
37 }
38 if c.CreatedAt.Equal(other.CreatedAt) {
39 // if we have the exact same creation date but the key is different
40 // we take the smallest UID using string alphabetical comparison to ensure stability.
41 if c.UID > other.UID {
42 *c = *other
43 return other, nil
44 }
45 return nil, nil
46 }
47 // if our seed is not the oldest, then we should request a change.
48 *c = *other
49 return other, nil
50}
51
52// MergeContent tells if the content of the two seeds are the same.
53func (c *ClusterSeed) MergeContent() []string {

Callers 15

XXX_MergeMethod · 0.80
XXX_MergeMethod · 0.80
XXX_MergeMethod · 0.80
EstimateMethod · 0.80
AdvanceMethod · 0.80
XXX_MergeMethod · 0.80
XXX_MergeMethod · 0.80
XXX_MergeMethod · 0.80
XXX_MergeMethod · 0.80
XXX_MergeMethod · 0.80
XXX_MergeMethod · 0.80
XXX_MergeMethod · 0.80

Calls 1

EqualMethod · 0.45

Tested by

no test coverage detected