-
Notifications
You must be signed in to change notification settings - Fork 103
/
taskq.go
42 lines (34 loc) · 1.18 KB
/
taskq.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
41
42
package taskq
import (
"context"
"log"
"os"
"time"
"github.com/go-redis/redis/v8"
"github.com/vmihailenco/taskq/v3/internal"
)
func init() {
SetLogger(log.New(os.Stderr, "taskq: ", log.LstdFlags|log.Lshortfile))
}
func SetLogger(logger *log.Logger) {
internal.Logger = logger
}
// Factory is an interface that abstracts creation of new queues.
// It is implemented in subpackages memqueue, azsqs, and ironmq.
type Factory interface {
RegisterQueue(*QueueOptions) Queue
Range(func(Queue) bool)
StartConsumers(context.Context) error
StopConsumers() error
Close() error
}
type Redis interface {
Del(ctx context.Context, keys ...string) *redis.IntCmd
SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.BoolCmd
Pipelined(ctx context.Context, fn func(pipe redis.Pipeliner) error) ([]redis.Cmder, error)
// Eval Required by redislock
Eval(ctx context.Context, script string, keys []string, args ...interface{}) *redis.Cmd
EvalSha(ctx context.Context, sha1 string, keys []string, args ...interface{}) *redis.Cmd
ScriptExists(ctx context.Context, scripts ...string) *redis.BoolSliceCmd
ScriptLoad(ctx context.Context, script string) *redis.StringCmd
}