feat(runtime): run durable workers continuously
This commit is contained in:
@@ -12,6 +12,7 @@ type WorkerCycleResult struct {
|
||||
RecoveredClaims int64
|
||||
DispatchID string
|
||||
Completed bool
|
||||
Idle bool
|
||||
}
|
||||
|
||||
func ExecuteWorkerCycle(ctx context.Context, store ports.WorkerStore, workerID string, token work.AgentFencingToken, now time.Time, staleAfter, leaseTTL time.Duration) (WorkerCycleResult, error) {
|
||||
@@ -23,6 +24,9 @@ func ExecuteWorkerCycle(ctx context.Context, store ports.WorkerStore, workerID s
|
||||
if err != nil {
|
||||
return WorkerCycleResult{RecoveredClaims: recovered}, err
|
||||
}
|
||||
if item.DispatchID == "" {
|
||||
return WorkerCycleResult{RecoveredClaims: recovered, Idle: true}, nil
|
||||
}
|
||||
intent, err := store.LoadDispatchIntent(ctx, item.DispatchID)
|
||||
if err != nil {
|
||||
_ = store.CompleteDispatch(ctx, item.DispatchID, workerID, work.AgentDispatchFailed, now.UnixMilli())
|
||||
|
||||
Reference in New Issue
Block a user