feat: add precise task business key and creation time queries

This commit is contained in:
2026-09-17 22:19:36 +08:00
parent a50d5faac7
commit 7641423f9d
32 changed files with 1105 additions and 93 deletions

View File

@@ -132,6 +132,21 @@ func (s *Service) ListTasks(ctx context.Context, token auth.Token, in ListInput)
default:
return TaskPage{}, fault.Invalid("invalid task state")
}
if !utf8.ValidString(in.BusinessKey) || utf8.RuneCountInString(in.BusinessKey) > 191 || strings.ContainsAny(in.BusinessKey, "\x00\r\n") {
return TaskPage{}, fault.Invalid("business_key must be at most 191 characters without control newlines")
}
for _, field := range []**time.Time{&in.CreatedFrom, &in.CreatedBefore} {
if *field != nil {
v := (**field).UTC()
if v.Year() < 2000 || v.Year() > 9998 || v.Nanosecond()%1000 != 0 {
return TaskPage{}, fault.Invalid("creation bounds must use supported years and microsecond precision")
}
*field = &v
}
}
if in.CreatedFrom != nil && in.CreatedBefore != nil && !in.CreatedFrom.Before(*in.CreatedBefore) {
return TaskPage{}, fault.Invalid("created_from must be before created_before")
}
return s.store.ListTasks(ctx, token, in)
}
func (s *Service) CancelTask(ctx context.Context, token auth.Token, id core.ID, key string, in CancelInput) (CancelResult, error) {