feat: add durable relative task delays and outage recovery regression

This commit is contained in:
2026-09-17 23:43:57 +08:00
parent 522fe2ef3e
commit a664ec9370
34 changed files with 811 additions and 28 deletions

View File

@@ -0,0 +1,25 @@
package schedule
import (
"encoding/json"
"testing"
"time"
core "git.yuntuo.hk/k2safe/orbit/model"
"git.yuntuo.hk/k2safe/orbit/pulse/service"
)
func TestScheduleDoesNotSilentlyIgnoreTaskDelay(t *testing.T) {
in := Definition{
Rule: Rule{Kind: "FIXED_RATE", Timezone: "UTC", StartAt: time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC), IntervalMS: 1000},
Policy: Policy{Misfire: "SKIP", Overlap: "PARALLEL", CatchupLimit: 1, CatchupWindowMS: 30000, GraceMS: 1000},
Task: service.SubmitInput{QueueID: core.ID("11111111111111111111111111111111"), Handler: "object.prepare", HandlerVersion: "v1", PayloadVersion: "v1", Payload: json.RawMessage(`{}`)},
}
if _, err := Normalize(in); err != nil {
t.Fatal(err)
}
in.Task.DelayMS = 1
if _, err := Normalize(in); err == nil {
t.Fatal("schedule accepted a delay outside its firing rule")
}
}