Repository navigation
TemporalOperationHandler context refactor #3195
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
Changes from all commits
233f825
7525d3e
7161e89
e819eb3
9fd257b
3eae86d
1793ab1
981cf95
2334f01
3dba9a5
d193c96
922d10b
13e0b6f
b78bec7
682d658
118f3c4
bb10b28
c03bf5f
acb17d0
29102bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,12 @@ | ||
| package io.temporal.internal.nexus; | ||
|
|
||
| import com.google.common.base.Strings; | ||
| import io.nexusrpc.OperationException; | ||
| import io.nexusrpc.handler.*; | ||
| import io.temporal.common.interceptors.NexusOperationInboundCallsInterceptor; | ||
| import io.temporal.common.interceptors.WorkerInterceptor; | ||
| import io.temporal.internal.concurrent.structured.CancelSource; | ||
| import java.util.concurrent.CancellationException; | ||
|
|
||
| public class TemporalInterceptorMiddleware implements OperationMiddleware { | ||
| private final WorkerInterceptor[] interceptors; | ||
|
|
@@ -24,14 +27,21 @@ public OperationHandler<Object, Object> intercept( | |
| } | ||
|
|
||
| InternalNexusOperationContext temporalNexusContext = CurrentNexusOperationContext.get(); | ||
| CancelSource<CancellationException> cancellationSource = | ||
| new CancelSource<>(() -> new CancellationException(context.getMethodCancellationReason())); | ||
| context.addMethodCancellationListener(cancellationSource::cancel); | ||
| inboundCallsInterceptor.init( | ||
| new RootNexusOperationOutboundCallsInterceptor( | ||
| temporalNexusContext.getMetricsScope(), | ||
| temporalNexusContext.getWorkflowClient(), | ||
| new NexusInfoImpl( | ||
| temporalNexusContext.getNamespace(), | ||
| temporalNexusContext.getTaskQueue(), | ||
| temporalNexusContext.getEndpoint()))); | ||
| temporalNexusContext.getEndpoint(), | ||
| context.getService(), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. service and operation weren't explicitly mentioned in the spec as something to keep in the NexusInfo. They are used in the tests to create a workflow ID. afaik, workflow ID is chosen in application code and we recommend that users set it to a meaningful business id., so we can probably remove it?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we decided to keep this because types are exposed within workflow and activity. |
||
| context.getOperation(), | ||
| Strings.emptyToNull(temporalNexusContext.getRequestId()), | ||
| cancellationSource.token()))); | ||
| return new OperationInterceptorConverter(inboundCallsInterceptor); | ||
| } | ||
|
|
||
|
|
||
This file was deleted.
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.
What about RequestID and Headers?
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 intentionally left both out of
Nexus.getInfo()based on the design clarification. Interceptors can still read the request headers, and the start-operation interceptors can read the request ID from the start details.Do you see a use case that needs either field directly in a handler?
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.
we decided to add requestId because its useful for request dedup
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.
headers we will punt on since they are accessible through interceptors