-
Notifications
You must be signed in to change notification settings - Fork 148
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
Interceptor refactoring #37
Conversation
… interceptor_threading
@@ -71,6 +71,10 @@ | |||
/** Throws Error in case of any unexpected condition. It is to fail a decision, not a workflow. */ | |||
class DeterministicRunnerImpl implements DeterministicRunner { | |||
|
|||
private static final int ROOT_THREAD_PRIORITY = 0; | |||
private static final int CALLBACK_THREAD_PRIORITY = 10; | |||
private static final int WORKFLOW_THREAD_PRIORITY = 20000000; |
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.
All workflow threads will have the same priority? Will that be a problem or co-operative multiple threading is good enough to guarantee 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.
These priorities are not Java thread priorities. They define the order of cooperative scheduling to ensure that signals are processed before the main method. And for the root thread we need it to ensure that it runs before the first signal is delivered in case of signalWithStart.
public void processSignal(String signalName, Object[] arguments, long eventId) { | ||
Method signalMethod = signalHandlers.get(signalName); | ||
try { | ||
newInstance(); |
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'm confused on why newInstance is created for both processSignal and execute calls. Is it expected that only one of them will ever be called?
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 is a noop if the instance is already created. But you are right that after my latest changes it belongs in init call.
UUID randomUUID(); | ||
|
||
void upsertSearchAttributes(Map<String, Object> searchAttributes); | ||
WorkflowInvoker interceptExecuteWorkflow( |
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.
Is that only going to be used by root context? Why signal is missing 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.
WorkflowInterceptor.interceptExecuteWorkflow returns WorkflowInvoker which has:
- init() called when workflow class is instantiated
- execute() called when main workflow method is executed
- processSignal() called for each signal.
Refactored workflow interceptor into: