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 @@ -29,6 +29,7 @@ public class DemoWorkflow extends Workflow {
public void run(WorkflowContext ctx) {
ctx.getLogger().info("Starting Workflow: " + ctx.getName());
ctx.getLogger().info("Instance ID: " + ctx.getInstanceId());
ctx.getLogger().info("Current Orchestration Time: " + ctx.getCurrentInstant());
ctx.getLogger().info("Waiting for event: 'myEvent'...");
try {
ctx.waitForExternalEvent("myEvent", Duration.ofSeconds(10)).await();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.slf4j.LoggerFactory;
import org.slf4j.helpers.NOPLogger;
import java.time.Duration;
import java.time.Instant;

/**
* Dapr workflow context implementation.
Expand Down Expand Up @@ -82,6 +83,13 @@ public String getInstanceId() {
return this.innerContext.getInstanceId();
}

/**
* {@inheritDoc}
*/
public Instant getCurrentInstant() {
return this.innerContext.getCurrentInstant();
}

/**
* {@inheritDoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.io.PrintStream;
import java.time.Duration;
import java.time.Instant;

/**
* Context object used by workflow implementations to perform actions such as scheduling activities,
Expand Down Expand Up @@ -49,6 +50,12 @@ public interface WorkflowContext {
*/
String getInstanceId();

Comment thread
julioalex-rezende marked this conversation as resolved.
/**
* Gets the current orchestration time in UTC.
* @return the current orchestration time in UTC
*/
Instant getCurrentInstant();

/**
* Completes the current workflow.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ public void getInstanceIdTest() {
verify(mockInnerContext, times(1)).getInstanceId();
}

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

@Test
public void waitForExternalEventTest() {
String expectedEvent = "TestEvent";
Expand Down