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

Function RecordOutput

recorded_output.go:53–70  ·  view source on GitHub ↗

RecordOutput records output JSON from a job. The "output" can be any JSON-encodable value and will be stored in the database on the job row after the current execution attempt completes. Output may be useful for debugging, or for storing the result of a job temporarily without needing to create a de

(ctx context.Context, output any)

Source from the content-addressed store, hash-verified

51// The output is marshalled to JSON as part of this function and it will return
52// an error if the output is not JSON-encodable.
53func RecordOutput(ctx context.Context, output any) error {
54 metadataUpdates, hasMetadataUpdates := jobexecutor.MetadataUpdatesFromWorkContext(ctx)
55 if !hasMetadataUpdates {
56 return errors.New("RecordOutput must be called within a Worker")
57 }
58
59 outputBytes, err := json.Marshal(output)
60 if err != nil {
61 return err
62 }
63
64 if err := checkOutputSize(outputBytes); err != nil {
65 return err
66 }
67
68 metadataUpdates[rivertype.MetadataKeyOutput] = json.RawMessage(outputBytes)
69 return nil
70}
71
72// Postgres JSONB is limited to 255MB, but it would be a bad idea to get
73// anywhere close to that limit for output.

Callers 3

Test_RecordedOutputFunction · 0.85
Test_Client_CommonFunction · 0.85
Test_Client_JobUpdateFunction · 0.85

Calls 2

checkOutputSizeFunction · 0.85

Tested by 3

Test_RecordedOutputFunction · 0.68
Test_Client_CommonFunction · 0.68
Test_Client_JobUpdateFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…