-
Notifications
You must be signed in to change notification settings - Fork 17
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
Refactoring: shared utilities and cleanup #313
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
package child_workflow.signal; | ||
|
||
import io.temporal.client.WorkflowClient; | ||
import io.temporal.client.WorkflowOptions; | ||
import io.temporal.sdkfeatures.Assertions; | ||
import io.temporal.sdkfeatures.Feature; | ||
import io.temporal.sdkfeatures.Run; | ||
|
@@ -13,37 +11,36 @@ | |
import io.temporal.workflow.Workflow; | ||
import io.temporal.workflow.WorkflowInterface; | ||
import io.temporal.workflow.WorkflowMethod; | ||
import java.time.Duration; | ||
|
||
@WorkflowInterface | ||
public interface feature extends Feature { | ||
|
||
@WorkflowInterface | ||
public interface ChildWorkflow { | ||
interface ChildWorkflow { | ||
|
||
@WorkflowMethod | ||
String workflow(); | ||
|
||
@SignalMethod | ||
void unblock(String message); | ||
} | ||
|
||
class ChildWorkflowImpl implements ChildWorkflow { | ||
/* | ||
* A workflow that waits for a signal and returns the data received. | ||
*/ | ||
class Impl implements ChildWorkflow { | ||
/* | ||
* A workflow that waits for a signal and returns the data received. | ||
*/ | ||
|
||
private String childWorkflowUnblockMessage; | ||
private String childWorkflowUnblockMessage; | ||
|
||
@Override | ||
public String workflow() { | ||
Workflow.await(() -> childWorkflowUnblockMessage != null); | ||
return childWorkflowUnblockMessage; | ||
} | ||
@Override | ||
public String workflow() { | ||
Workflow.await(() -> childWorkflowUnblockMessage != null); | ||
return childWorkflowUnblockMessage; | ||
} | ||
|
||
@Override | ||
public void unblock(String message) { | ||
childWorkflowUnblockMessage = message; | ||
@Override | ||
public void unblock(String message) { | ||
childWorkflowUnblockMessage = message; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The diff here is mostly indentation, moving an impl into the interface - easier to understand with hide-whitespace on. |
||
} | ||
} | ||
|
||
|
@@ -54,7 +51,7 @@ class Impl implements feature { | |
|
||
@Override | ||
public void prepareWorker(Worker worker) { | ||
worker.registerWorkflowImplementationTypes(ChildWorkflowImpl.class); | ||
worker.registerWorkflowImplementationTypes(ChildWorkflow.Impl.class); | ||
} | ||
|
||
private static final String UNBLOCK_MESSAGE = "unblock"; | ||
|
@@ -78,15 +75,7 @@ public String workflow() { | |
|
||
@Override | ||
public Run execute(Runner runner) throws Exception { | ||
var options = | ||
WorkflowOptions.newBuilder() | ||
.setTaskQueue(runner.config.taskQueue) | ||
.setWorkflowExecutionTimeout(Duration.ofMinutes(1)) | ||
.build(); | ||
var stub = runner.client.newWorkflowStub(feature.class, options); | ||
var execution = WorkflowClient.start(stub::workflow); | ||
var method = runner.featureInfo.metadata.getWorkflowMethods().get(0); | ||
return new Run(method, execution); | ||
return runner.executeSingleParameterlessWorkflow(); | ||
} | ||
|
||
@Override | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The diff in the file is easier to understand with hide-whitespace on: spotless converting 4-space to 2-space indentation.
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.
Greatly appreciated! I think on the Java SDK there is an auto-formatter. I wonder if we want to bring that over 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.
You do have the "spotless" autoformatter active here, which is what made these changes. I guess it tolerates both 4- and 2-space indentation depending on context and I caused it to flip. But I thought I'd let it do its thing because it seems we mostly use 2 spaces.