Skip to content
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

Merged
merged 1 commit into from
Oct 21, 2021
Merged

feat!: Restructure code in prep for vm transition #317

merged 1 commit into from
Oct 21, 2021

Conversation

bergundy
Copy link
Member

@bergundy bergundy commented Oct 20, 2021

  • 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.

@bergundy
Copy link
Member Author

In a follow up PR we'll probably rename external dependencies to "sinks".

@bergundy bergundy marked this pull request as ready for review October 20, 2021 20:48
@bergundy bergundy self-assigned this Oct 20, 2021
@bergundy bergundy enabled auto-merge (squash) October 20, 2021 20:53
*
* @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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 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

Copy link
Member Author

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.

*/
maxCachedWorkflows?: number;

/**
* TODO: document
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Todo needs fixin' ?

Comment on lines 849 to 871
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,
});
}
})();
}
Copy link
Member

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?

Copy link
Member

@Sushisource Sushisource left a 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.
@bergundy bergundy changed the title chore: Restructure code in prep for vm transition feat!: Restructure code in prep for vm transition Oct 21, 2021
@bergundy bergundy enabled auto-merge (squash) October 21, 2021 03:12
@bergundy bergundy merged commit 3bd1c0e into main Oct 21, 2021
@bergundy bergundy deleted the vm-prep branch October 21, 2021 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants