temporalio / sdk-go

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

Support interceptor on WorkflowRun.Get #1351

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

Quinn-With-Two-Ns commented 8 months ago

Is your feature request related to a problem? Please describe. When using a context aware data converter that uses the workflow ID (or any workflow options), the workflows result will be encoded using the workflow ID. When reading the workflow result the data converter must also have the workflow ID passed. With every other client call to a workflow execution this can be set in the interceptor, except for getting the workflow result because there is no interceptor.

Describe the solution you'd like Support interceptor on WorkflowRun.Get

Java SDK Also supports it:

https://javadoc.io/static/io.temporal/temporal-sdk/1.22.3/io/temporal/common/interceptors/WorkflowClientCallsInterceptor.html#getResult(io.temporal.common.interceptors.WorkflowClientCallsInterceptor.GetResultInput)

Quinn-With-Two-Ns commented 8 months ago

related: https://github.com/temporalio/sdk-go/issues/1349

cretz commented 8 months ago

Note, many other SDKs (TS, Python, and .NET) do not support intercepting result fetching. Java is unique here. Most, including Go, support wrapping the result from start to customize result fetching. But as for manually getting a workflow run/handle, only Java seems to be able to do this. If we agree we need this functionality generally we can create a general purpose feature for it so those SDKs can add it too.

I am not sure SDKs are usually expected to be able to use workflow-specific information in all ways a data converter is invoked by a client. They can just use contextual information set by the caller (so #1349 does make sense).

Quinn-With-Two-Ns commented 8 months ago

Most, including Go, support wrapping the result from start to customize result fetching

Go does not support intercepting client.GetWorkflow so you cannot always wrap automatically wrap WorkflowResult. If we have to add an interceptor for client.GetWorkflow might as well just add the interceptor to get a result

I am not sure SDKs are usually expected to be able to use workflow-specific information in all ways a data converter is invoked by a client.

Maybe not every call, but any call specifically to a workflow execution should be able to access workflow specific information. For client calls the interceptor injecting those values is a suitable solution for all client calls