- R4:封存子进程 SIGTERM 宽限停、libraryctl 信号转 ctx;失败/超时后 agent 再做 有界 recover,恢复失败即降级阻断封存并给出原因;启动先恢复、关闭等恢复完成 - R5:封存闸口以已存 payload 为准,同作业号换范围 409 且不入新队;重放回显真实状态 - R6:作业列表按类型查询(ListByType),不再先取全局再过滤 - R7:根目录 libraryagent 二进制移出版本库,保留运行产物并精确忽略 - UI:发布管理只保留对内/对外两目标,整合快照/完整性/作业/存储;链路未接线项禁用 并标原因;整库版本独立导航并入;文档级旧流程折叠保留
This commit is contained in:
@@ -132,6 +132,18 @@ RETURNING job_id
|
||||
SELECT id FROM updated
|
||||
`
|
||||
|
||||
// One job type, newest first: a caller which needs "the recent jobs of MY type"
|
||||
// must not page the global queue (other traffic would hide its own rows).
|
||||
const listJobsByTypeSQL = `
|
||||
SELECT id, type, payload, state, priority, available_at,
|
||||
lease_owner, lease_until, attempt, max_attempts,
|
||||
last_error, idempotency_key, created_at, updated_at
|
||||
FROM jobs
|
||||
WHERE type = $1
|
||||
ORDER BY created_at DESC, id DESC
|
||||
LIMIT $2
|
||||
`
|
||||
|
||||
const listJobsSQL = `
|
||||
SELECT id, type, payload, state, priority, available_at,
|
||||
lease_owner, lease_until, attempt, max_attempts,
|
||||
|
||||
@@ -65,6 +65,31 @@ func (s *Store) Claim(ctx context.Context, workerID string, allowedTypes []strin
|
||||
return job, nil
|
||||
}
|
||||
|
||||
// ListByType lists only the requested job type, so a busy queue cannot hide the
|
||||
// caller's own recent jobs behind unrelated traffic.
|
||||
func (s *Store) ListByType(ctx context.Context, jobType string, limit int) ([]jobs.Job, error) {
|
||||
if strings.TrimSpace(jobType) == "" || limit < 1 || limit > 200 {
|
||||
return nil, errors.New("list jobs by type requires a type and a bounded limit")
|
||||
}
|
||||
rows, err := s.db.Query(ctx, listJobsByTypeSQL, jobType, limit)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("list jobs by type: %w", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
result := make([]jobs.Job, 0, limit)
|
||||
for rows.Next() {
|
||||
job, err := scanJob(rows)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("scan listed job: %w", err)
|
||||
}
|
||||
result = append(result, *job)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, fmt.Errorf("iterate jobs: %w", err)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *Store) List(ctx context.Context, limit int) ([]jobs.Job, error) {
|
||||
rows, err := s.db.Query(ctx, listJobsSQL, limit)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user