Skip to content

Added HelloCancellationScope - #37

Merged
mfateev merged 11 commits into
temporalio:developfrom
mfateev:cancel_others
Aug 22, 2020
Merged

mfateev merged 11 commits into
temporalio:developfrom
mfateev:cancel_others

Conversation

@mfateev

@mfateev mfateev commented Aug 21, 2020

Copy link
Copy Markdown
Member

No description provided.

@mfateev
mfateev requested a review from shawnhathaway August 21, 2020 03:56
@mfateev
mfateev requested a review from samarabbas August 21, 2020 23:02
sleep(1);
try {
context.heartbeat(i);
} catch (ActivityCompletionException e) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Usage of ActivityCompletionException here is not clear. Considering this specific sample is in the context of cancellation I think we should explain why we are handling ActivityCompletionException here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added comment

@samarabbas samarabbas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We also need a readme for this sample.

@rylandg rylandg left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Mostly nitpick. Overall looks good.

scope.run();
// Wait for one of the activities to complete.
Promise.anyOf(results).get();
// Cancel all other activities

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: "cancel uncompleted activities"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done

scope.cancel();
// Get the result from one of the Promises.
String result = null;
for (int i = 0; i < greetings.length; i++) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would rely on anyOf result if possible instead of the loop

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done

// client that can be used to start and signal workflows
WorkflowClient client = WorkflowClient.newInstance(service);

// worker factory that can be used to create workers for specific task queues

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: "Worker"

.setMaxConcurrentActivityExecutionSize(100)
.setActivityPollThreadCount(1)
.build());
// Workflows are stateful. So you need a type to create instances.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don't think this will make sense to someone reading the Sample.


// worker factory that can be used to create workers for specific task queues
WorkerFactory factory = WorkerFactory.newInstance(client);
// Worker that listens on a task queue and hosts both workflow and activity implementations.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Not sure how helpful this comment is.

public static void main(String[] args) {
// gRPC stubs wrapper that talks to the local docker instance of temporal service.
WorkflowServiceStubs service = WorkflowServiceStubs.newInstance();
// client that can be used to start and signal workflows

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Are you starting comments with caps or lower? Also do comments end in periods?

@mfateev
mfateev merged commit cf78e2d into temporalio:develop Aug 22, 2020
@mfateev
mfateev deleted the cancel_others branch August 22, 2020 21:21
@mfateev mfateev mentioned this pull request Aug 23, 2020
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.

3 participants