Skip to content

Commit

Permalink
Fix fail n times worker
Browse files Browse the repository at this point in the history
  • Loading branch information
boney9 committed Sep 29, 2023
1 parent 11c878f commit 27f6d76
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main/java/io/orkes/samples/workers/FailNTimesWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
import org.springframework.stereotype.Component;

import java.time.Instant;
import java.time.ZoneId;
import java.util.Map;

@Component
public class FailNTimesWorker implements Worker {

public static final String ZONE = "America/Los_Angeles";

@Override
public String getTaskDefName() {
return "fail_n_times";
Expand All @@ -18,10 +22,10 @@ public String getTaskDefName() {
@Override
public TaskResult execute(Task task) {
TaskResult result = new TaskResult(task);
if(!task.isRetried()) {
result.addOutputData("initialStartTime", Instant.ofEpochMilli(task.getStartTime()).toString());
result.addOutputData("initialTaskExecutionTime", Instant.now().toString());
result.addOutputData("initialScheduledTime", Instant.ofEpochMilli(task.getScheduledTime()).toString());
if(task.getRetryCount() == 0) {
result.addOutputData("initialStartTime", Instant.ofEpochMilli(task.getStartTime()).atZone(ZoneId.of(ZONE)).toString());
result.addOutputData("initialTaskExecutionTime", Instant.now().atZone(ZoneId.of(ZONE)).toString());
result.addOutputData("initialScheduledTime", Instant.ofEpochMilli(task.getScheduledTime()).atZone(ZoneId.of(ZONE)).toString());
}
int timesToFail = getIntValue("timesToFail", 1, task.getInputData());
int failedCount = getIntValue("failedCount", 0, task.getOutputData());
Expand Down

0 comments on commit 27f6d76

Please sign in to comment.