temporalio / sdk-go

Temporal Go SDK
https://docs.temporal.io/application-development?lang=go
MIT License
544 stars 215 forks source link

Context aware data converters cannot get IDs of outbound activities and child workflow #1352

Open Quinn-With-Two-Ns opened 10 months ago

Quinn-With-Two-Ns commented 10 months ago

Is your feature request related to a problem? Please describe. Context aware data converters should have some way to get ID of outbound activities and child workflows when the data converter is being used to serialize activity input or child workflow input. This is useful if the data converter changes behaviour based on the workflow ID, for example using the ID as associated data for encryption.

In the Java SDK this is trivial because the Java SDK will pass the child workflow ID to the data converter when serializing the child workflow input

Describe the solution you'd like I can think of acceptable solutions:

  1. Users could create an interceptor to manually set the activity ID/ child workflow ID, maybe the SDK can provide some random generator to help create deterministic UUIDs. Other SDK already have helpers for this so maybe it is worth doing regardless.

  2. Ideally the ID would be accessible in the WithContext or WithWorkflowContext call on the data converter. When we generate the ID in question we could set it on the context and pass that context with the ID to the context aware data converter. This would require some minor refactoring to when the SDK generates an activity ID/ child workflow ID

cretz commented 10 months ago

I vote option 2. In theory one shouldn't expect an activity or workflow context to even be created without associated info that contains their ID.