Skip to content

Commit 8d05f80

Browse files
committed
Review comments
Signed-off-by: joshvanl <me@joshvanl.dev>
1 parent 3cbc0e1 commit 8d05f80

5 files changed

Lines changed: 54 additions & 13 deletions

File tree

‎durabletask-client/src/main/java/io/dapr/durabletask/DurableTaskClient.java‎

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -524,10 +524,8 @@ public void suspendInstance(String instanceId, @Nullable String reason, @Nullabl
524524
* @param pageSize the maximum number of instance IDs to return, or null for no limit
525525
* @return the raw list-instance-IDs response from the sidecar
526526
*/
527-
public OrchestratorService.ListInstanceIDsResponse listInstanceIds(
528-
@Nullable String continuationToken, @Nullable Integer pageSize) {
529-
return this.listInstanceIds(continuationToken, pageSize, null);
530-
}
527+
public abstract OrchestratorService.ListInstanceIDsResponse listInstanceIds(
528+
@Nullable String continuationToken, @Nullable Integer pageSize);
531529

532530
/**
533531
* Lists workflow instance IDs with optional pagination, keeping only the IDs that start with a prefix.
@@ -536,9 +534,16 @@ public OrchestratorService.ListInstanceIDsResponse listInstanceIds(
536534
* @param pageSize the maximum number of instance IDs to return, or null for no limit
537535
* @param instanceIdPrefix only instance IDs that start with this prefix are returned, or null for all
538536
* @return the raw list-instance-IDs response from the sidecar
537+
* @throws UnsupportedOperationException if a prefix is given and this implementation cannot filter by one
539538
*/
540-
public abstract OrchestratorService.ListInstanceIDsResponse listInstanceIds(
541-
@Nullable String continuationToken, @Nullable Integer pageSize, @Nullable String instanceIdPrefix);
539+
public OrchestratorService.ListInstanceIDsResponse listInstanceIds(
540+
@Nullable String continuationToken, @Nullable Integer pageSize, @Nullable String instanceIdPrefix) {
541+
if (instanceIdPrefix == null || instanceIdPrefix.isEmpty()) {
542+
return this.listInstanceIds(continuationToken, pageSize);
543+
}
544+
throw new UnsupportedOperationException(
545+
"listing instance IDs by prefix is not supported by this DurableTaskClient implementation");
546+
}
542547

543548
/**
544549
* Gets the full execution history of a workflow instance.
@@ -568,15 +573,19 @@ public abstract String rerunWorkflowFromEvent(String sourceInstanceId, int event
568573
* @param input the input given to every run. Must be serializable. May be null.
569574
* @param overwrite true to replace an existing schedule of the same name
570575
*/
571-
public abstract void createWorkflowSchedule(WorkflowSchedule schedule, @Nullable Object input, boolean overwrite);
576+
public void createWorkflowSchedule(WorkflowSchedule schedule, @Nullable Object input, boolean overwrite) {
577+
throw schedulesUnsupported();
578+
}
572579

573580
/**
574581
* Gets a workflow schedule with its status.
575582
*
576583
* @param name the name of the schedule
577584
* @return the schedule
578585
*/
579-
public abstract WorkflowSchedule getWorkflowSchedule(String name);
586+
public WorkflowSchedule getWorkflowSchedule(String name) {
587+
throw schedulesUnsupported();
588+
}
580589

581590
/**
582591
* Lists workflow schedules with their status, with optional pagination.
@@ -585,23 +594,38 @@ public abstract String rerunWorkflowFromEvent(String sourceInstanceId, int event
585594
* @param pageSize the maximum number of schedules to return, or null for no limit
586595
* @return the raw list-workflow-schedules response from the sidecar
587596
*/
588-
public abstract ListWorkflowSchedulesResponse listWorkflowSchedules(
589-
@Nullable String continuationToken, @Nullable Integer pageSize);
597+
public ListWorkflowSchedulesResponse listWorkflowSchedules(
598+
@Nullable String continuationToken, @Nullable Integer pageSize) {
599+
throw schedulesUnsupported();
600+
}
590601

591602
/**
592603
* Deletes a workflow schedule. Runs it already started are not affected.
593604
*
594605
* @param name the name of the schedule
595606
*/
596-
public abstract void deleteWorkflowSchedule(String name);
607+
public void deleteWorkflowSchedule(String name) {
608+
throw schedulesUnsupported();
609+
}
597610

598611
/**
599612
* Starts a run of a workflow schedule now, without changing when its next scheduled run is.
600613
*
601614
* @param name the name of the schedule
602615
* @return the instance ID of the run
603616
*/
604-
public abstract String triggerWorkflowSchedule(String name);
617+
public String triggerWorkflowSchedule(String name) {
618+
throw schedulesUnsupported();
619+
}
620+
621+
/**
622+
* Rejects a workflow schedule call on a client that does not implement schedules. Implementations that
623+
* support them override the schedule methods, so this is only reached on ones that do not.
624+
*/
625+
private static UnsupportedOperationException schedulesUnsupported() {
626+
return new UnsupportedOperationException(
627+
"workflow schedules are not supported by this DurableTaskClient implementation");
628+
}
605629

606630
/**
607631
* Rejects a cross-app target on a client that does not implement cross-app routing. Implementations that

‎durabletask-client/src/main/java/io/dapr/durabletask/DurableTaskGrpcClient.java‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,12 @@ public String restartInstance(String instanceId, boolean restartWithNewInstanceI
555555
return this.scheduleNewOrchestrationInstance(metadata.getName(), options);
556556
}
557557

558+
@Override
559+
public OrchestratorService.ListInstanceIDsResponse listInstanceIds(
560+
@Nullable String continuationToken, @Nullable Integer pageSize) {
561+
return this.listInstanceIds(continuationToken, pageSize, null);
562+
}
563+
558564
@Override
559565
public OrchestratorService.ListInstanceIDsResponse listInstanceIds(
560566
@Nullable String continuationToken, @Nullable Integer pageSize, @Nullable String instanceIdPrefix) {

‎sdk-workflows/src/main/java/io/dapr/workflows/client/WorkflowRuntimeStatus.java‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public enum WorkflowRuntimeStatus {
5555
/**
5656
* The workflow was suspended.
5757
*/
58-
SUSPENDED
58+
SUSPENDED,
59+
60+
/**
61+
* The workflow is stalled: it makes no progress until the cause recorded in its history is fixed.
62+
*/
63+
STALLED
5964

6065
}

‎sdk-workflows/src/main/java/io/dapr/workflows/runtime/WorkflowRuntimeStatusConverter.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public static WorkflowRuntimeStatus fromOrchestrationRuntimeStatus(Orchestration
5050
return WorkflowRuntimeStatus.PENDING;
5151
case SUSPENDED:
5252
return WorkflowRuntimeStatus.SUSPENDED;
53+
case STALLED:
54+
return WorkflowRuntimeStatus.STALLED;
5355
default:
5456
throw new IllegalArgumentException(String.format("Unknown status value: %s", status));
5557
}

‎sdk-workflows/src/test/java/io/dapr/workflows/runtime/WorkflowRuntimeStatusConverterTest.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ public void fromOrchestrationRuntimeStatus() {
5656
assertEquals(WorkflowRuntimeStatus.SUSPENDED,
5757
WorkflowRuntimeStatusConverter.fromOrchestrationRuntimeStatus(OrchestrationRuntimeStatus.SUSPENDED)
5858
);
59+
60+
assertEquals(WorkflowRuntimeStatus.STALLED,
61+
WorkflowRuntimeStatusConverter.fromOrchestrationRuntimeStatus(OrchestrationRuntimeStatus.STALLED)
62+
);
5963
}
6064

6165
@Test

0 commit comments

Comments
 (0)