feat(monitor): 死信中文提示与成功/取消自动退信
This commit is contained in:
@@ -87,13 +87,24 @@ func (s *Store) List(ctx context.Context, limit int) ([]jobs.Job, error) {
|
||||
}
|
||||
|
||||
func (s *Store) Complete(ctx context.Context, id, owner string, now time.Time) error {
|
||||
tag, err := s.db.Exec(ctx, completeJobSQL, id, owner, now)
|
||||
tx, err := s.db.Begin(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("complete job: %w", err)
|
||||
}
|
||||
defer func() { _ = tx.Rollback(ctx) }()
|
||||
tag, err := tx.Exec(ctx, completeJobSQL, id, owner, now)
|
||||
if err != nil {
|
||||
return fmt.Errorf("complete job: %w", err)
|
||||
}
|
||||
if tag.RowsAffected() != 1 {
|
||||
return ErrLeaseLost
|
||||
}
|
||||
if _, err := tx.Exec(ctx, retireOpenFailuresSQL, id, now); err != nil {
|
||||
return fmt.Errorf("complete job: retire failures: %w", err)
|
||||
}
|
||||
if err := tx.Commit(ctx); err != nil {
|
||||
return fmt.Errorf("complete job: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user