MCPcopy Index your code
hub / github.com/riverqueue/river / metadataEqual

Function metadataEqual

producer.go:1092–1109  ·  view source on GitHub ↗

metadataEqual compares two JSON byte slices for semantic equality by parsing them into maps and re-marshaling them. This handles cases where the JSON is equivalent but formatted differently (whitespace, field order, etc).

(a, b []byte)

Source from the content-addressed store, hash-verified

1090// them into maps and re-marshaling them. This handles cases where the JSON is
1091// equivalent but formatted differently (whitespace, field order, etc).
1092func metadataEqual(a, b []byte) bool {
1093 var unmarshaledA, unmarshaledB map[string]any
1094 if err := json.Unmarshal(a, &unmarshaledA); err != nil {
1095 return false
1096 }
1097 if err := json.Unmarshal(b, &unmarshaledB); err != nil {
1098 return false
1099 }
1100 marshaledA, err := json.Marshal(unmarshaledA)
1101 if err != nil {
1102 return false
1103 }
1104 marshaledB, err := json.Marshal(unmarshaledB)
1105 if err != nil {
1106 return false
1107 }
1108 return bytes.Equal(marshaledA, marshaledB)
1109}

Callers 1

pollForSettingChangesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…