-
Notifications
You must be signed in to change notification settings - Fork 4
/
repository.go
40 lines (31 loc) · 1.54 KB
/
repository.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package tasq
import (
"context"
"time"
"github.com/google/uuid"
)
// Ordering is an enum type describing the polling strategy utitlized during
// the polling process.
type Ordering int
// The collection of orderings.
const (
OrderingCreatedAtFirst Ordering = iota
OrderingPriorityFirst
)
// IRepository describes the mandatory methods a repository must implement
// in order for tasq to be able to use it.
type IRepository interface {
Migrate(ctx context.Context) error
PingTasks(ctx context.Context, taskIDs []uuid.UUID, visibilityTimeout time.Duration) ([]*Task, error)
PollTasks(ctx context.Context, types, queues []string, visibilityTimeout time.Duration, ordering Ordering, limit int) ([]*Task, error)
CleanTasks(ctx context.Context, minimumAge time.Duration) (int64, error)
RegisterStart(ctx context.Context, task *Task) (*Task, error)
RegisterError(ctx context.Context, task *Task, errTask error) (*Task, error)
RegisterFinish(ctx context.Context, task *Task, finishStatus TaskStatus) (*Task, error)
SubmitTask(ctx context.Context, task *Task) (*Task, error)
DeleteTask(ctx context.Context, task *Task, safeDelete bool) error
RequeueTask(ctx context.Context, task *Task) (*Task, error)
ScanTasks(ctx context.Context, taskStatuses []TaskStatus, taskTypes, queues []string, ordering Ordering, limit int) ([]*Task, error)
CountTasks(ctx context.Context, taskStatuses []TaskStatus, taskTypes, queues []string) (int64, error)
PurgeTasks(ctx context.Context, taskStatuses []TaskStatus, taskTypes, queues []string, safeDelete bool) (int64, error)
}