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

Function MetadataSet

metadata.go:26–38  ·  view source on GitHub ↗

MetadataSet records a metadata value to be merged into the job's metadata when the current work attempt finishes. This function is only valid from a worker, worker middleware, or work hook like rivertype.HookWorkBegin or rivertype.HookWorkEnd. Metadata updates are stored on the work context and me

(ctx context.Context, key string, value any)

Source from the content-addressed store, hash-verified

24// Keys prefixed with `river:` are reserved for internal use and may not be set
25// by user code.
26func MetadataSet(ctx context.Context, key string, value any) error {
27 if strings.HasPrefix(key, "river:") {
28 return errors.New("MetadataSet cannot be used with keys prefixed with `river:`")
29 }
30
31 metadataUpdates, ok := jobexecutor.MetadataUpdatesFromWorkContext(ctx)
32 if !ok {
33 return errMetadataNotSettable
34 }
35
36 metadataUpdates[key] = value
37 return nil
38}

Callers 2

TestMetadataSetFunction · 0.85
Test_Client_CommonFunction · 0.85

Calls 1

Tested by 2

TestMetadataSetFunction · 0.68
Test_Client_CommonFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…