-
Notifications
You must be signed in to change notification settings - Fork 109
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
[Feature Request] Go over WF activation logic #202
Comments
Activations consist of multiple jobs. Suggestion for how node will process activations:
Does that make sense @Sushisource @mfateev? |
Looks good to me. There was a request to process signals one by one for the given type. It would be nice to make it default: temporalio/sdk-java#214 |
@mfateev I'm not sure the Java issue is relevant to us. Example: export function myWorkflow() {
const channel = new UnboundedChannel();
return {
async execute() {
for await (const signal of channel) {
// handle signal
}
},
signals: {
userInput(input: any) {
channel.send(input);
}
}
};
} |
I think the node alternative would be not delivering a new signal until the |
Why though? |
It sounds like there are 2 options: A. Signals are delivered as they're received The Java SDK will default to B, and maybe have A as an option. For Node, we currently only support A. We could support B or document how to ensure sequential execution, like with the code snippet above. Support BA con is complicating the API. Eg saying "after the arguments that you provide to your signal function, you can pass an additional options arg for Temporal to read":
A pro is the user doesn't have to code it. Another con is complicating our advice on how to write workflows. Currently, you can do whatever you want in a signal handler, but with B support, we'd say eg "if you have deliverSequentially on, then don't do long-running logic or sleeping in your signal handlers, because you wouldn't be able to receive signals". Versus if we don't support B, it's clear from looking at the code when a I think I prefer not supporting B. As a Node dev, I'm used to the thought that my current function (eg an HTTP request handler) is going to be called non-sequentially, and program accordingly. It makes sense to me that a Signal, as a message from an outside system, would arrive and result in my handler being executed in the same fashion. |
I agree with @lorensr here. export function myWorkflow() {
const signals = { userInput: new UnboundedChannel() };
return {
async execute() {
for await (const signal of signals.userInput) {
// handle signal
}
},
signals,
};
} |
Currently there are some TODOs in the codebase for executing signals first and handling activation errors.
We also wait for microtasks to run between each job, make sure that's really required.
The text was updated successfully, but these errors were encountered: