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

Jira/iwf 273 Add/fix javadocs for exception thrown #265

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 84 additions & 12 deletions src/main/java/io/iworkflow/core/Client.java

Large diffs are not rendered by default.

21 changes: 17 additions & 4 deletions src/main/java/io/iworkflow/core/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
public abstract class Context {
public abstract Long getWorkflowStartTimestampSeconds();

/**
* @return the StateExecutionId.
* Only applicable for state methods (waitUntil or execute)
*/
public abstract Optional<String> getStateExecutionId();

public abstract String getWorkflowRunId();
Expand All @@ -16,11 +20,20 @@ public abstract class Context {

public abstract String getWorkflowType();

// this is the start time of the first attempt of the API call. It's from ScheduledTimestamp of Cadence/Temporal activity.GetInfo
// require server version 1.2.2+, return -1 if server version is lower
/**
* @return the start time of the first attempt of the state method invocation.
* Only applicable for state methods (waitUntil or execute)
*/
public abstract Optional<Long> getFirstAttemptTimestampSeconds();

// Attempt starts from 1, and increased by 1 for every retry if retry policy is specified. It's from Attempt of Cadence/Temporal activity.GetInfo
// require server version 1.2.2+, return -1 if server version is lower
/**
* @return attempt starts from 1, and increased by 1 for every retry if retry policy is specified.
*/
public abstract Optional<Integer> getAttempt();

/**
* @return the requestId that is used to start the child workflow from state method.
* Only applicable for state methods (waitUntil or execute)
*/
public abstract Optional<String> getChildWorkflowRequestId();
Copy link
Contributor Author

@longquanzheng longquanzheng Nov 14, 2024

Choose a reason for hiding this comment

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

cc @lwolczynski This is a helper for using the requestId feature in AlreadyStartedOption, so that it can hide some details there (see an internal link in iwf-samples)

}
1 change: 1 addition & 0 deletions src/main/java/io/iworkflow/core/RPC.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
* Only used when workflow has enabled {@link PersistenceOptions} CachingPersistenceByMemo
* By default, it's false for high throughput support
* flip to true to bypass the caching for strong consistent reads
* @return true if bypass caching for strong consistency
*/
boolean bypassCachingForStrongConsistency() default false;
}
2 changes: 1 addition & 1 deletion src/main/java/io/iworkflow/core/StateDecision.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public static <I> StateDecision singleNextState(final Class<? extends WorkflowSt
* singleNextState as non-strongly typing required for input
* @param stateClass required
* @param stateInput optional, can be null
* @return
* @return state decision
*/
public static StateDecision singleNextStateUntypedInput(final Class<? extends WorkflowState> stateClass, final Object stateInput) {
return singleNextState(stateClass.getSimpleName(), stateInput, null);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/io/iworkflow/core/WorkerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ private Context fromIdlContext(final io.iworkflow.gen.models.Context context, fi
.workflowRunId(context.getWorkflowRunId())
.workflowStartTimestampSeconds(context.getWorkflowStartedTimestamp())
.stateExecutionId(Optional.ofNullable(context.getStateExecutionId()))
.childWorkflowRequestId(context.getWorkflowRunId()+"-"+context.getStateExecutionId())
.attempt(attempt)
.firstAttemptTimestampSeconds(firstAttemptTimestamp)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ public interface Communication {
* trigger new state movements as the RPC results
* NOTE: closing workflows like completing/failing are not supported
* NOTE: Only used in RPC -- cannot be used in state APIs
*
* @param stateMovements
* @param stateMovements the state movements to trigger
*/
void triggerStateMovements(final StateMovement... stateMovements);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

import io.iworkflow.core.ClientSideException;

public class NoRunningWorkflowException extends WorkflowNotExistsOrOpenException {
/**
* A friendly named exception to indicate that the workflow does not exist or exists but not running.
* It's the same as {@link WorkflowNotExistsException} but with a different name.
* It's subclass of {@link ClientSideException} with ErrorSubStatus.WORKFLOW_NOT_EXISTS_SUB_STATUS
*/
public class NoRunningWorkflowException extends WorkflowNotExistsException {
public NoRunningWorkflowException(
final ClientSideException exception) {
super(exception);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.iworkflow.core.exceptions;

import io.iworkflow.core.ClientSideException;

/**
* A friendly named exception to indicate that the workflow does not exist
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lwolczynski I want to remove the deprecated one becaue I believe no one is using it(should be the same for OSS users).
But I realized that we need this WorkflowNotExistsException as well as NoRunningWorkflowException, because in some cases either one makes sense.

For example, for signalWorkflow API, the exception is thrown because the workflow is not open, or not exists, so NoRunningWorkflowException makes sense, but not WorkflowNotExistsException.
For getDataAttribute API, the exception is only thrown when the workflow not exists, so NoRunningWorkflowException doesn't make sense.

* It's subclass of {@link ClientSideException} with ErrorSubStatus.WORKFLOW_NOT_EXISTS_SUB_STATUS
*/
public class WorkflowNotExistsException extends ClientSideException {
public WorkflowNotExistsException(
final ClientSideException exception) {
super(exception);
}
}

This file was deleted.

Loading