-
Notifications
You must be signed in to change notification settings - Fork 137
Eager Workflow Start #1757
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
Eager Workflow Start #1757
Conversation
24a1314
to
9d137ac
Compare
|
||
const start = composeInterceptors(interceptors, 'start', this._startWorkflowHandler.bind(this)); | ||
// Adapt legacy `start` interceptors to the new `startWithDetails` interface. | ||
const adaptedInterceptors: WorkflowClientInterceptor[] = interceptors.map((i) => { |
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.
Nits:
- Should probably move these adaptors to a distinct file. The
workflow-client.ts
file is already quite heavy. - I think we should adapt interceptors on Client creation, so that we don't have to do this repeatedly here.
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.
moved to interceptor-adapters.ts
I tried moving the adapt interceptors logic to client creation, but it causes an otel interceptor test to fail (Otel interceptor spans are connected and complete
). I spent probably too much time trying to debug this (I believe it has to do with losing this
context when we try to transform the interceptor), but wasn't able to solve it without resorting back to does this transformation directly in _start
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.
Just had a very quick look. Deferring to @Sushisource for more complete check.
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.
Looking good to me. Just minor stuff about comments.
// Apply adapters to workflow client interceptor. | ||
export function adaptWorkflowClientInterceptor(i: WorkflowClientInterceptor): WorkflowClientInterceptor { |
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.
Comment mostly just repeats function name. The comment for the "real" function seems sufficient.
packages/client/src/interceptors.ts
Outdated
* Successor to {@link start}. Unlike {@link start}, this method returns | ||
* start details via {@link WorkflowStartOutput}. |
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.
This comment will need to change when the deprecated start is removed. I'd get rid of the reference to the old thing and just talk about what it does.
const interceptors = Array.isArray(this.options.interceptors) | ||
? (this.options.interceptors as WorkflowClientInterceptor[]) | ||
: []; | ||
// Apply adapters to workflow client interceptors. |
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.
Obvious comment
* Potentially reduce the latency to start this workflow by encouraging the server to | ||
* start it on a local worker running with this same client. |
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.
* Potentially reduce the latency to start this workflow by encouraging the server to | |
* start it on a local worker running with this same client. | |
* Potentially reduce the latency to start this workflow by requesting that the server | |
* start it on a local worker running with this same client. |
- add startWithDetails to WorkflowClientInterceptor to support return type of WorkflowStartOutput, inject if not defined at _start call
- symbol usage to mark if connection supports ews - separate file for interceptor adapters, adapt wf client interceptors on wf client creation - deprecate `start` wf client interceptor in favor of `startWithDetails`
9638f7f
to
33d672c
Compare
What was changed
The main change to accommodate eager workflow start was adding
startWithDetails
toWorkflowClientInterceptor
to support a (new) return type ofWorkflowStartOutput
. This allows us to return an object, giving us the ability to add new fields without issue - we addeagerlyStarted
in this PR. This new interceptor method is injected if not defined at the internal_start
call, and adapts the existingstart
interceptor method to usestartWithDetails
. We also define a new handle calledWorkflowHandleWithStartDetails
which extends the existingWorkflowHandleWithFirstExecutionRunId
, which now includes whether the workflow was started eagerly or not. Adding fields to the handle is an adopted pattern in the TS SDK.Why?
Support eager workflow start.
Closes [Feature Request] Eager Workflow Start #1348
How was this tested:
Existing integration tests and 2 new integration tests.
Any docs updates needed?
Probably