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

Function computeNewValue

kv/memberlist/memberlist_client.go:1823–1839  ·  view source on GitHub ↗

returns [result, change, error]

(incoming Mergeable, incomingValueRequiresClone bool, oldVal Mergeable, cas bool)

Source from the content-addressed store, hash-verified

1821
1822// returns [result, change, error]
1823func computeNewValue(incoming Mergeable, incomingValueRequiresClone bool, oldVal Mergeable, cas bool) (Mergeable, Mergeable, error) {
1824 if oldVal == nil {
1825 // It's OK to return the same value twice (once as result, once as change), because "change" will be cloned
1826 // in mergeValueForKey if needed.
1827
1828 if incomingValueRequiresClone {
1829 clone := incoming.Clone()
1830 return clone, clone, nil
1831 }
1832
1833 return incoming, incoming, nil
1834 }
1835
1836 // otherwise we have two mergeables, so merge them
1837 change, err := oldVal.Merge(incoming, cas)
1838 return oldVal, change, err
1839}
1840
1841func (m *KV) storeCopy() map[string]ValueDesc {
1842 m.storeMu.Lock()

Callers 1

mergeValueForKeyMethod · 0.85

Calls 2

CloneMethod · 0.65
MergeMethod · 0.65

Tested by

no test coverage detected