Schedules leave the schedules control-plane resource for State Store tables behind a ScheduleService contract. A run is claimed per schedule slot, missed slots fire once, the next run stays on the schedule's grid, cron is read in the schedule-settings time zone, and failed runs are recorded and advance. Three failures in a row raise a schedule.failing alert. A fired run records a schedule-fired capture. Run history is pruned by age and count. Removes the chat and spawn-task runners, the dangerous-payload guard and the old schedules settings page.
40 lines
941 B
Go
40 lines
941 B
Go
package postgres
|
|
|
|
import (
|
|
"errors"
|
|
"unicode/utf8"
|
|
|
|
"github.com/jackc/pgx/v5/pgconn"
|
|
)
|
|
|
|
// clip limits s to n bytes without splitting a UTF-8 rune.
|
|
func clip(s string, n int) string {
|
|
if len(s) <= n {
|
|
return s
|
|
}
|
|
pos := 0
|
|
for pos < len(s) {
|
|
_, size := utf8.DecodeRuneInString(s[pos:])
|
|
if pos+size > n {
|
|
break
|
|
}
|
|
pos += size
|
|
}
|
|
return s[:pos]
|
|
}
|
|
|
|
// isUniqueViolation reports whether err is a PostgreSQL unique-constraint
|
|
// violation (SQLSTATE 23505), matching the SQLite store's "UNIQUE constraint
|
|
// failed" string test rather than grepping driver error text.
|
|
func isUniqueViolation(err error) bool {
|
|
var pgErr *pgconn.PgError
|
|
return errors.As(err, &pgErr) && pgErr.Code == "23505"
|
|
}
|
|
|
|
// isForeignKeyViolation reports whether err is a PostgreSQL foreign-key
|
|
// violation (SQLSTATE 23503).
|
|
func isForeignKeyViolation(err error) bool {
|
|
var pgErr *pgconn.PgError
|
|
return errors.As(err, &pgErr) && pgErr.Code == "23503"
|
|
}
|