2
0
mirror of https://github.com/hibiken/asynq.git synced 2024-09-20 11:05:58 +08:00
asynq/asynq.go
Ken Hibino 1b1662bb12 Add Retry method to *RDB
(*RDB).Retry method takes a TaskMessage and will atomically moves the
message from in_progress queue to retry queue. Additionally it
increments the Retried counter and assigns the error message to the
message.
2019-12-15 16:15:07 -08:00

49 lines
1.3 KiB
Go

package asynq
import "github.com/go-redis/redis/v7"
/*
TODOs:
- [P0] Proper OS Signal handling
- [P0] Wait for a certain amount of time for wokers to finish on TERM signal
- [P0] asynqmon kill <taskID>, asynqmon killall <qname>
- [P0] Assigning int or any number type to Payload will be converted to float64 in handler
- [P0] Redis Memory Usage, Connection info in stats
- [P0] Processed, Failed count for today
- [P0] Go docs + CONTRIBUTION.md + Github issue template + License comment
- [P0] Redis Sentinel support
- [P1] Add Support for multiple queues and priority
- [P1] User defined max-retry count
*/
// Max retry count by default
const defaultMaxRetry = 25
// Task represents a task to be performed.
type Task struct {
// Type indicates the kind of the task to be performed.
Type string
// Payload is an arbitrary data needed for task execution.
// The value has to be serializable.
Payload map[string]interface{}
}
// RedisConfig specifies redis configurations.
// TODO(hibiken): Support more configuration.
type RedisConfig struct {
Addr string
Password string
// DB specifies which redis database to select.
DB int
}
func newRedisClient(cfg *RedisConfig) *redis.Client {
return redis.NewClient(&redis.Options{
Addr: cfg.Addr,
Password: cfg.Password,
DB: cfg.DB,
})
}