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

Method mergeBytesValueForKey

kv/memberlist/memberlist_client.go:1721–1738  ·  view source on GitHub ↗
(key string, incomingData []byte, codec codec.Codec, deleted bool, updateTime time.Time)

Source from the content-addressed store, hash-verified

1719}
1720
1721func (m *KV) mergeBytesValueForKey(key string, incomingData []byte, codec codec.Codec, deleted bool, updateTime time.Time) (Mergeable, uint, bool, time.Time, error) {
1722 // Even if there is no change to the Mergeable, we still may need to update the timestamp and deleted state.
1723 if len(incomingData) == 0 {
1724 incomingData = emptySnappyEncodedData
1725 }
1726 decodedValue, err := codec.Decode(incomingData)
1727 if err != nil {
1728 return nil, 0, false, time.Time{}, fmt.Errorf("failed to decode value: %v", err)
1729 }
1730
1731 incomingValue, ok := decodedValue.(Mergeable)
1732 if !ok {
1733 return nil, 0, false, time.Time{}, fmt.Errorf("expected Mergeable, got: %T", decodedValue)
1734 }
1735
1736 // No need to clone this "incomingValue", since we have just decoded it from bytes, and won't be using it.
1737 return m.mergeValueForKey(key, incomingValue, false, 0, codec.CodecID(), deleted, updateTime)
1738}
1739
1740// Merges incoming value with value we have in our store. Returns "a change" that can be sent to other
1741// cluster members to update their state, and new version of the value.

Callers 2

processValueUpdateMethod · 0.95
MergeRemoteStateMethod · 0.95

Calls 4

mergeValueForKeyMethod · 0.95
ErrorfMethod · 0.80
DecodeMethod · 0.65
CodecIDMethod · 0.65

Tested by

no test coverage detected