2019-11-15 13:07:19 +08:00
|
|
|
package asynq
|
|
|
|
|
2019-12-04 13:01:26 +08:00
|
|
|
import "github.com/go-redis/redis/v7"
|
2019-11-22 22:16:43 +08:00
|
|
|
|
2019-11-17 06:45:51 +08:00
|
|
|
/*
|
|
|
|
TODOs:
|
2019-12-11 12:28:31 +08:00
|
|
|
- [P0] asynqmon kill <taskID>, asynqmon killall <qname>
|
2019-12-19 13:18:13 +08:00
|
|
|
- [P0] Pagination for `asynqmon ls` command
|
2019-12-18 12:37:54 +08:00
|
|
|
- [P0] Show elapsed time for InProgress tasks (asynqmon ls inprogress)
|
2019-12-11 12:28:31 +08:00
|
|
|
- [P0] Redis Memory Usage, Connection info in stats
|
|
|
|
- [P0] Processed, Failed count for today
|
2019-12-13 11:05:25 +08:00
|
|
|
- [P0] Go docs + CONTRIBUTION.md + Github issue template + License comment
|
2019-12-11 12:28:31 +08:00
|
|
|
- [P0] Redis Sentinel support
|
2019-11-24 08:44:22 +08:00
|
|
|
- [P1] Add Support for multiple queues and priority
|
2019-11-18 07:36:33 +08:00
|
|
|
- [P1] User defined max-retry count
|
2019-11-17 06:45:51 +08:00
|
|
|
*/
|
|
|
|
|
2019-11-18 05:25:01 +08:00
|
|
|
// Max retry count by default
|
2019-12-11 13:38:25 +08:00
|
|
|
const defaultMaxRetry = 25
|
2019-11-18 05:25:01 +08:00
|
|
|
|
2019-11-15 13:07:19 +08:00
|
|
|
// Task represents a task to be performed.
|
|
|
|
type Task struct {
|
2019-11-17 06:45:51 +08:00
|
|
|
// Type indicates the kind of the task to be performed.
|
|
|
|
Type string
|
|
|
|
|
2019-12-19 23:13:43 +08:00
|
|
|
// Payload holds data needed for the task execution.
|
|
|
|
Payload Payload
|
2019-11-15 13:07:19 +08:00
|
|
|
}
|
|
|
|
|
2019-12-04 11:43:01 +08:00
|
|
|
// RedisConfig specifies redis configurations.
|
2019-12-09 22:52:43 +08:00
|
|
|
// TODO(hibiken): Support more configuration.
|
2019-12-04 11:43:01 +08:00
|
|
|
type RedisConfig struct {
|
2019-11-15 13:07:19 +08:00
|
|
|
Addr string
|
|
|
|
Password string
|
2019-11-25 10:41:55 +08:00
|
|
|
|
|
|
|
// DB specifies which redis database to select.
|
|
|
|
DB int
|
2019-11-15 13:07:19 +08:00
|
|
|
}
|
2019-12-01 23:59:52 +08:00
|
|
|
|
2019-12-09 22:22:08 +08:00
|
|
|
func newRedisClient(cfg *RedisConfig) *redis.Client {
|
2019-12-04 13:01:26 +08:00
|
|
|
return redis.NewClient(&redis.Options{
|
2019-12-09 22:22:08 +08:00
|
|
|
Addr: cfg.Addr,
|
|
|
|
Password: cfg.Password,
|
|
|
|
DB: cfg.DB,
|
2019-12-04 13:01:26 +08:00
|
|
|
})
|
2019-12-02 22:55:04 +08:00
|
|
|
}
|