-
Notifications
You must be signed in to change notification settings - Fork 158
Add WorkflowStubCallsInterceptor which provides an access to Headers #382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add WorkflowStubCallsInterceptor which provides an access to Headers #382
Conversation
b4b89bd
to
a5f1d1c
Compare
17ea722
to
300a66b
Compare
300a66b
to
cc6df07
Compare
I might be missing something, but there is already a way to pass headers to the |
@vitarb Yeah, probably you are missing a context. sdk-java/temporal-sdk/src/main/java/io/temporal/internal/sync/SyncWorkflowContext.java Line 458 in cc6df07
That's the context of Issue #373. This PR is the last missing piece for Issue #373. Adding an ability to modify headers in client stub interceptors. This was the first PR in this series #375
Nah, as far as I know. An alternative solution that is lighter will actually be bothering of Worflow stub interface and passing Headers there in a start method. But it will 1. break backward compatibility 2. Expose Headers as a part of WorkflowStub interface that is not internal and a part of public API. That's why I chose this way of implementing it, especially because it's the closest way to Worker Interceptors by how it works. |
Discussed over zoom call, concluded that there is an alternative path through setting headers in workflow options (either using context propagators or adding a separate field(?)), which we can access through workflow stub in the My main concern with this PR is that it looks like a bit of an overkill for simply setting headers. On the other hand I do see value in having more generic solution. If we aim for a more generic approach though we should consider other use cases and make sure that it is actually generic enough to handle them. Dmitry is going to implement this approach as well and then we can discuss both of them with @mfateev and decide which one we want. |
…ptor. Drafted for discussion for PR temporalio#382
…ptor. Drafted for discussion for PR temporalio#382
36430fe
to
9d54b25
Compare
Partially addresses temporalio#373.
9d54b25
to
fb8363a
Compare
@vitarb @mfateev could you guys please revisit this PR? It's pretty much done.
Please feel free to leave any naming suggestions for anything created in this PR, I will revisit your comments and amend the names that I used. |
temporal-sdk/src/main/java/io/temporal/common/interceptors/WorkflowClientInterceptor.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've fixed the build failure, it was due to warnings because of a couple of missing annotations.
Otherwise everything is looking good to me, thanks for the contribution!
Before merging in, I would like Maxim to take a glimpse too.
*/ | ||
WorkflowSignalOutput signal(WorkflowSignalInput input); | ||
|
||
WorkflowStartOutput signalWithStart(WorkflowStartWithSignalInput input); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The input class name is not consistent with the method name.
I would create a separate structure for output as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Created WorkflowSignalWithStartOutput that has WorkflowStartOutput as a field to mirror the input structure.
temporal-sdk/src/main/java/io/temporal/common/interceptors/WorkflowClientCallsInterceptor.java
Outdated
Show resolved
Hide resolved
temporal-sdk/src/main/java/io/temporal/internal/client/RootWorkflowClientInvoker.java
Outdated
Show resolved
Hide resolved
temporal-sdk/src/main/java/io/temporal/internal/client/RootWorkflowClientInvoker.java
Outdated
Show resolved
Hide resolved
temporal-sdk/src/main/java/io/temporal/internal/sync/WorkflowStubImpl.java
Outdated
Show resolved
Hide resolved
ba6def0
to
0809cab
Compare
What was changed:
Added new
WorkflowClientCallsInterceptor
with the same idea and implemented in the same way asWorkflowOutboundCallsInterceptor
,WorkflowInboundCallsInterceptor
,ActivityInboundCallsInterceptor
that provides Header access.Part of WorkflowStubImpl is refactored to be implemented in a similar manner with
SyncWorkflowContext implements WorkflowOutboundCallsInterceptor
.Why?
We need to have client interceptors with access to Headers.
The reason to add a new interceptor interface is an inability to wire Headers in the existing
WorkflowClientInterceptor/WorkflowStub
, because it would expose Headers to WorkflowStub client code and break compatibility. Also, this solution adds an Interceptor that is organized the same way as Worker Interceptors.Closes
Partially addresses #373.