feat: schedule due processing from next dueAt instead of polling
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -11,6 +11,7 @@ import com.jetlumen.ordo.api.runtime.ProcessContext;
|
||||
import com.jetlumen.ordo.api.runtime.ProcessEvent;
|
||||
import com.jetlumen.ordo.api.runtime.ProcessInstance;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -40,6 +41,9 @@ public interface OrdoEngine {
|
||||
/** Claims and processes up to {@code limit} overdue pending tasks. {@code limit} must be positive. */
|
||||
int processDue(int limit);
|
||||
|
||||
/** Earliest {@code dueAt} among pending tasks, or empty if none are scheduled. */
|
||||
Optional<Instant> nextDueAt();
|
||||
|
||||
default ProcessInstance withdraw(String instanceId, String actor) {
|
||||
return withdraw(instanceId, actor, null);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,9 @@ public interface ApprovalTaskRepository {
|
||||
|
||||
List<ApprovalTask> findDuePending(Instant now, int limit);
|
||||
|
||||
/** Earliest {@code dueAt} among pending tasks, or empty if none are scheduled. */
|
||||
Optional<Instant> findNextDueAt();
|
||||
|
||||
boolean claimIfDue(String taskId, String expectedAssignee, Instant now);
|
||||
|
||||
/** Paginated, filterable query; results are ordered newest-first (created_at desc). */
|
||||
|
||||
Reference in New Issue
Block a user