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

Interceptor refactoring #37

Merged
merged 9 commits into from
Mar 22, 2020
Merged

Interceptor refactoring #37

merged 9 commits into from
Mar 22, 2020

Conversation

mfateev
Copy link
Member

@mfateev mfateev commented Mar 21, 2020

Refactored workflow interceptor into:

  • WorkflowInterceptor
  • WorkflowCallsInterceptor
  • WorkflowInvocationInterceptor
  • WorkflowInvoker

@mfateev mfateev requested a review from samarabbas March 21, 2020 21:37
@@ -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;

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?

Copy link
Member Author

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();

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?

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 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(

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?

Copy link
Member Author

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.

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