feat: add durable relative task delays and outage recovery regression
This commit is contained in:
@@ -52,15 +52,32 @@ func run() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
businessKey := "object /+% é " + op + " "
|
||||
businessKey := "对象 /+% é " + op + " "
|
||||
var tasks []orbit.Task
|
||||
for i, key := range []string{businessKey, businessKey, businessKey[:len(businessKey)-1]} {
|
||||
out, err := client.SubmitTask(ctx, fmt.Sprintf("query-%s-%d", op, i), orbit.SubmitTaskRequest{QueueID: queue, Handler: "query." + op, HandlerVersion: "v1", PayloadVersion: "v1", Payload: json.RawMessage(`{"object_ref":"examples/input"}`), BusinessKey: key, TaskTimeoutMS: 60000})
|
||||
payload := json.RawMessage(`{"object_ref":"examples/input","format":"text"}`)
|
||||
if i == 1 {
|
||||
payload = json.RawMessage(`{"object_ref":"examples/input","format":"json"}`)
|
||||
}
|
||||
out, err := client.SubmitTask(ctx, fmt.Sprintf("query-%s-%d", op, i), orbit.SubmitTaskRequest{QueueID: queue, Handler: "query." + op, HandlerVersion: "v1", PayloadVersion: "v1", Payload: payload, BusinessKey: key, TaskTimeoutMS: 60000})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tasks = append(tasks, out.Task)
|
||||
}
|
||||
// 改参数使用新身份与相同关联键,读取旧任务确认原输入仍保留。
|
||||
for _, task := range tasks[:2] {
|
||||
current, err := client.GetTask(ctx, task.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if string(current.Payload) != string(task.Payload) {
|
||||
return errors.New("new linked submission changed existing input")
|
||||
}
|
||||
}
|
||||
if tasks[0].ID == tasks[1].ID || string(tasks[0].Payload) == string(tasks[1].Payload) {
|
||||
return errors.New("parameter change did not create an independent task")
|
||||
}
|
||||
from, before := tasks[0].CreatedAt, tasks[2].CreatedAt.Add(time.Microsecond)
|
||||
query := orbit.ListTasksRequest{QueueID: queue, State: orbit.TaskWaiting, BusinessKey: businessKey, CreatedFrom: &from, CreatedBefore: &before, Limit: 1}
|
||||
matched, pages := 0, 0
|
||||
@@ -99,6 +116,6 @@ func run() error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
fmt.Printf("matched=%d pages=%d before_excluded=true cancelled=%d\n", matched, pages, len(tasks))
|
||||
fmt.Printf("matched=%d pages=%d before_excluded=true original_payload_preserved=true cancelled=%d\n", matched, pages, len(tasks))
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user