-
Notifications
You must be signed in to change notification settings - Fork 105
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
feat!: Restructure code in prep for vm transition #317
Conversation
In a follow up PR we'll probably rename external dependencies to "sinks". |
* | ||
* @see proposal at https://github.com/temporalio/proposals/blob/master/node/logging-and-metrics-for-user-code.md | ||
* Dependency functions may not return values to the Workflow in order to prevent breaking determinism. |
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.
* Dependency functions may not return values to the Workflow in order to prevent breaking determinism. | |
* Dependency functions may not return values to the Workflow in order to help prevent breaking determinism. |
Can't actually always prevent it
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.
It prevents this mechanism from interfering with the Workflow execution.
packages/worker/src/worker.ts
Outdated
*/ | ||
maxCachedWorkflows?: number; | ||
|
||
/** | ||
* TODO: document |
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.
Todo needs fixin' ?
packages/worker/src/worker.ts
Outdated
const externalCalls = await state.workflow.getAndResetExternalCalls(); | ||
const { dependencies } = this.options; | ||
for (const { ifaceName, fnName, args } of externalCalls) { | ||
const dep = dependencies?.[ifaceName]?.[fnName]; | ||
if (dep === undefined) { | ||
this.log.error('Workflow referenced an unregistrered external dependency', { | ||
ifaceName, | ||
fnName, | ||
}); | ||
} else if (dep.callDuringReplay || !activation.isReplaying) { | ||
(async () => { | ||
try { | ||
await dep.fn({ ...state.info, isReplaying: activation.isReplaying }, ...args); | ||
} catch (error) { | ||
this.log.error('External dependency function threw an error', { | ||
ifaceName, | ||
fnName, | ||
error, | ||
workflowInfo: state?.info, | ||
}); | ||
} | ||
})(); | ||
} |
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.
Can this bit be extracted to a function w/ a docstring?
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.
Definitely nicer. Nothing blocking.
- Decrease Workflow bundle size from ~7.44MB to ~2.75MB - Remove otel module from `@temporalio/common` default export - Rename `WorkflowIsolateBuilder` to `WorkflowCodeBundler` and remove unused methods - Add `Workflow` and `WorkflowCreator` interfaces to support pluggable workflow environments (prepare for VM) - Simplify external dependencies mechanism to only support `void` functions and remove the `isolated-vm` transfer options.
@temporalio/common
default exportWorkflowIsolateBuilder
toWorkflowCodeBundler
and removeunused methods
Workflow
andWorkflowCreator
interfaces to support pluggableworkflow environments (prepare for VM)
void
functions and remove the
isolated-vm
transfer options.