Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,9 @@ public void complete(Object output) {
public Task<Void> waitForExternalEvent(String eventName, Duration timeout) {
return this.innerContext.waitForExternalEvent(eventName, timeout);
}

@Override
public boolean getIsReplaying() {
return this.innerContext.getIsReplaying();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,21 @@ public interface WorkflowContext {
* @return Asynchronous task to {@code await()}.
*/
Task waitForExternalEvent(String eventName, Duration timeout);

/**
* Gets a value indicating whether the workflow is currently replaying a previous execution.
*
* <p>Workflow functions are "replayed" after being unloaded from memory to reconstruct local variable state.
* During a replay, previously executed tasks will be completed automatically with previously seen values
* that are stored in the workflow history. Once the workflow reaches the point where it's no longer
* replaying existing history, this method will return {@code false}.
*
* <p>You can use this method if you have logic that needs to run only when <em>not</em> replaying. For example,
* certain types of application logging may become too noisy when duplicated as part of replay. The
* application code could check to see whether the function is being replayed and then issue the log statements
* when this value is {@code false}.
*
* @return {@code true} if the workflow is replaying, otherwise {@code false}
*/
boolean getIsReplaying();
Comment thread
julioalex-rezende marked this conversation as resolved.
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,16 @@ public void completeTest() {
verify(mockInnerContext, times(1)).complete(null);
}

@Test
public void getIsReplaying() {
context.getIsReplaying();
verify(mockInnerContext, times(1)).getIsReplaying();
}

@Test
public void getLoggerReplayingTest() {
Logger mockLogger = mock(Logger.class);
when(mockInnerContext.getIsReplaying()).thenReturn(true);
when(context.getIsReplaying()).thenReturn(true);
Comment thread
julioalex-rezende marked this conversation as resolved.
DaprWorkflowContextImpl testContext = new DaprWorkflowContextImpl(mockInnerContext, mockLogger);

String expectedArg = "test print";
Expand All @@ -80,7 +86,7 @@ public void getLoggerReplayingTest() {
@Test
public void getLoggerFirstTimeTest() {
Logger mockLogger = mock(Logger.class);
when(mockInnerContext.getIsReplaying()).thenReturn(false);
when(context.getIsReplaying()).thenReturn(false);
DaprWorkflowContextImpl testContext = new DaprWorkflowContextImpl(mockInnerContext, mockLogger);
Comment thread
julioalex-rezende marked this conversation as resolved.

String expectedArg = "test print";
Expand Down