thread-master/apps/backend/internal/module/job/domain/repository.go

22 lines
1.1 KiB
Go
Raw Normal View History

2026-07-13 01:15:30 +00:00
package domain
import "context"
type Repository interface {
Insert(ctx context.Context, j *Job) error
Update(ctx context.Context, j *Job) error
FindByID(ctx context.Context, id string) (*Job, error)
ListByOwner(ctx context.Context, ownerUID int64) ([]*Job, error)
2026-07-13 03:18:08 +00:00
// ListByOwnerTab 分頁分桶total 為該 tab 總筆數
ListByOwnerTab(ctx context.Context, ownerUID int64, tab string, page, pageSize int) (list []*Job, total int64, err error)
2026-07-13 01:15:30 +00:00
// ClaimNext picks oldest due pending/queued (run_after <= now) and sets running + workerID.
ClaimNext(ctx context.Context, workerID string) (*Job, error)
// CancelPendingByRef cancels pending/queued jobs of template+ref (e.g. reschedule renew).
CancelPendingByRef(ctx context.Context, ownerUID int64, template, refID string) error
// Delete hard-removes a job by id.
Delete(ctx context.Context, id string) error
// DeleteTerminalBefore removes terminal jobs whose completion time is before beforeNs.
// Returns number of deleted documents.
DeleteTerminalBefore(ctx context.Context, beforeNs int64) (int64, error)
}