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

safe message passing sample #681

Merged
merged 8 commits into from
Oct 30, 2024

Conversation

Quinn-With-Two-Ns
Copy link
Contributor

@Quinn-With-Two-Ns Quinn-With-Two-Ns changed the title Sdk 2751 safe message passing sample Oct 4, 2024
Copy link
Contributor

@dandavison dandavison left a comment

Choose a reason for hiding this comment

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

Nice, all looks good, except I have a concern that we're doing start/stop wrong in all our samples (except Go?).

try {
Thread.sleep(100);
} catch (InterruptedException e) {
throw new RuntimeException(e);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you educate me on why we convert the one exception into the other?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

InterruptedException is a checked exception so we need to translate it to a unchecked exception

// to make it easier to pass between runs
class ClusterManagerState {
public boolean clusterStarted;
public boolean clusterShutdown;
Copy link
Contributor

@dandavison dandavison Oct 4, 2024

Choose a reason for hiding this comment

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

These are mutually exclusive -- can we use an enum for them? (Also as booleans would it be more idiomatic in java for them to start with is or does that only apply to methods?)


@Override
public void stopCluster() {
Workflow.await(() -> state.clusterStarted);
Copy link
Contributor

@dandavison dandavison Oct 4, 2024

Choose a reason for hiding this comment

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

So if someone sends the stop signal by mistake, it will just hang, and then the next time they start the cluster it will suddenly stop. That seems undesirable. That suggests this should be an update, so we can return success/fail.

(It's the same in the other non-Go languages)

}

@Override
public void startCluster() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to check that the cluster's in an appropriate state to proceed to the next lines. That suggests this should be an update, so we can return success/fail.

(If so it's a bug in the other non-Go languages)

@Quinn-With-Two-Ns
Copy link
Contributor Author

@dandavison thanks for the feedback, I updated the sample based on what you did in TS

Copy link
Contributor

@dandavison dandavison left a comment

Choose a reason for hiding this comment

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

LGTM!

…terManagerWorkflowImpl.java

Co-authored-by: Dan Davison <[email protected]>
@Quinn-With-Two-Ns Quinn-With-Two-Ns merged commit 5c96864 into temporalio:main Oct 30, 2024
5 checks passed
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