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

Function ExtractValues

rivershared/structtag/struct_tag.go:16–33  ·  view source on GitHub ↗

ExtractValues extracts the raw JSON values of the specified keys from the JSON-encoded args.

(encodedArgs []byte, uniqueKeys []string)

Source from the content-addressed store, hash-verified

14
15// ExtractValues extracts the raw JSON values of the specified keys from the JSON-encoded args.
16func ExtractValues(encodedArgs []byte, uniqueKeys []string) []string {
17 // Use GetManyBytes to retrieve multiple values at once
18 results := gjson.GetManyBytes(encodedArgs, uniqueKeys...)
19
20 uniqueValues := make([]string, len(results))
21 for i, res := range results {
22 if res.Exists() {
23 uniqueValues[i] = res.Raw // Use Raw to get the JSON-encoded value
24 } else {
25 // Handle missing keys as "undefined" (they'll be skipped when
26 // building the key). We don't want to use "null" here because the
27 // JSON may actually contain "null" as a value.
28 uniqueValues[i] = "undefined"
29 }
30 }
31
32 return uniqueValues
33}
34
35type uniqueFieldCacheKey struct {
36 typ reflect.Type

Callers 2

buildUniqueKeyStringFunction · 0.92
TestExtractValuesFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestExtractValuesFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…