-
Notifications
You must be signed in to change notification settings - Fork 21
/
interfaces.go
34 lines (28 loc) · 1.16 KB
/
interfaces.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
package tasqueue
import (
"context"
"time"
)
type Results interface {
Get(ctx context.Context, id string) ([]byte, error)
// NilError is used to check internally if the "id" is missing
NilError() error
Set(ctx context.Context, id string, b []byte) error
// DeleteJob removes the job's saved metadata from the store
DeleteJob(ctx context.Context, id string) error
GetFailed(ctx context.Context) ([]string, error)
GetSuccess(ctx context.Context) ([]string, error)
SetFailed(ctx context.Context, id string) error
SetSuccess(ctx context.Context, id string) error
}
type Broker interface {
// Enqueue places a task in the queue
Enqueue(ctx context.Context, msg []byte, queue string) error
// EnqueueScheduled accepts a task (msg, queue) and also a timestamp
// The job should be enqueued at the particular timestamp.
EnqueueScheduled(ctx context.Context, msg []byte, queue string, ts time.Time) error
// Consume listens for tasks on the queue and calls processor
Consume(ctx context.Context, work chan []byte, queue string)
// GetPending returns a list of stored job messages on the particular queue
GetPending(ctx context.Context, queue string) ([]string, error)
}