Skip to content

Commit

Permalink
Jira/iwf 273 Add/fix javadocs for exception thrown (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
longquanzheng authored Nov 15, 2024
1 parent 4484a27 commit fc0d00e
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 34 deletions.
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();
}
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
* 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.

0 comments on commit fc0d00e

Please sign in to comment.