Search code examples
gocadence-workflowtemporal-workflow

Is there a way to add fields to the workflow context that will be provided to all activities in the workflow?


I've seen BackgroundActivityContext as a way to provide global resources to activities, but is there any way to provide values scoped to an individual workflow run to all the activities in that workflow through context rather than as explicit parameters to the activity? The use case I'm thinking of is to provide something like a user id that the workflow execution relates to and that could then be added as a field to logs from an activity even if the activity doesn't take the user id as a parameter.


Solution

  • Implement your own ContextPropagator. Here is an example you can use as an inspiration.