Documentation
¶
Overview ¶
Package asynqtest defines test helpers for asynq and its internal packages.
Index ¶
- Variables
- func FlushDB(tb testing.TB, r *redis.Client)
- func GetDeadMessages(tb testing.TB, r *redis.Client) []*base.TaskMessage
- func GetEnqueuedMessages(tb testing.TB, r *redis.Client, queueOpt ...string) []*base.TaskMessage
- func GetInProgressMessages(tb testing.TB, r *redis.Client) []*base.TaskMessage
- func GetRetryMessages(tb testing.TB, r *redis.Client) []*base.TaskMessage
- func GetScheduledMessages(tb testing.TB, r *redis.Client) []*base.TaskMessage
- func MustMarshal(tb testing.TB, msg *base.TaskMessage) string
- func MustMarshalSlice(tb testing.TB, msgs []*base.TaskMessage) []string
- func MustUnmarshal(tb testing.TB, data string) *base.TaskMessage
- func MustUnmarshalSlice(tb testing.TB, data []string) []*base.TaskMessage
- func NewTaskMessage(taskType string, payload map[string]interface{}) *base.TaskMessage
- func NewTaskMessageWithQueue(taskType string, payload map[string]interface{}, qname string) *base.TaskMessage
- func SeedDeadQueue(tb testing.TB, r *redis.Client, entries []ZSetEntry)
- func SeedEnqueuedQueue(tb testing.TB, r *redis.Client, msgs []*base.TaskMessage, queueOpt ...string)
- func SeedInProgressQueue(tb testing.TB, r *redis.Client, msgs []*base.TaskMessage)
- func SeedRetryQueue(tb testing.TB, r *redis.Client, entries []ZSetEntry)
- func SeedScheduledQueue(tb testing.TB, r *redis.Client, entries []ZSetEntry)
- type ZSetEntry
Constants ¶
This section is empty.
Variables ¶
var IgnoreIDOpt = cmpopts.IgnoreFields(base.TaskMessage{}, "ID")
IgnoreIDOpt is an cmp.Option to ignore ID field in task messages when comparing.
var SortMsgOpt = cmp.Transformer("SortTaskMessages", func(in []*base.TaskMessage) []*base.TaskMessage { out := append([]*base.TaskMessage(nil), in...) sort.Slice(out, func(i, j int) bool { return out[i].ID.String() < out[j].ID.String() }) return out })
SortMsgOpt is a cmp.Option to sort base.TaskMessage for comparing slice of task messages.
var SortProcessInfoOpt = cmp.Transformer("SortProcessInfo", func(in []*base.ProcessInfo) []*base.ProcessInfo { out := append([]*base.ProcessInfo(nil), in...) sort.Slice(out, func(i, j int) bool { if out[i].Host != out[j].Host { return out[i].Host < out[j].Host } return out[i].PID < out[j].PID }) return out })
SortProcessInfoOpt is a cmp.Option to sort base.ProcessInfo for comparing slice of process info.
var SortStringSliceOpt = cmp.Transformer("SortStringSlice", func(in []string) []string { out := append([]string(nil), in...) sort.Strings(out) return out })
SortStringSliceOpt is a cmp.Option to sort string slice.
var SortWorkerInfoOpt = cmp.Transformer("SortWorkerInfo", func(in []*base.WorkerInfo) []*base.WorkerInfo { out := append([]*base.WorkerInfo(nil), in...) sort.Slice(out, func(i, j int) bool { return out[i].ID.String() < out[j].ID.String() }) return out })
SortWorkerInfoOpt is a cmp.Option to sort base.WorkerInfo for comparing slice of worker info.
var SortZSetEntryOpt = cmp.Transformer("SortZSetEntries", func(in []ZSetEntry) []ZSetEntry { out := append([]ZSetEntry(nil), in...) sort.Slice(out, func(i, j int) bool { return out[i].Msg.ID.String() < out[j].Msg.ID.String() }) return out })
SortZSetEntryOpt is an cmp.Option to sort ZSetEntry for comparing slice of zset entries.
Functions ¶
func GetDeadMessages ¶
func GetDeadMessages(tb testing.TB, r *redis.Client) []*base.TaskMessage
GetDeadMessages returns all task messages in the dead queue.
func GetEnqueuedMessages ¶
func GetEnqueuedMessages(tb testing.TB, r *redis.Client, queueOpt ...string) []*base.TaskMessage
GetEnqueuedMessages returns all task messages in the specified queue.
If queue name option is not passed, it defaults to the default queue.
func GetInProgressMessages ¶
func GetInProgressMessages(tb testing.TB, r *redis.Client) []*base.TaskMessage
GetInProgressMessages returns all task messages in the in-progress queue.
func GetRetryMessages ¶
func GetRetryMessages(tb testing.TB, r *redis.Client) []*base.TaskMessage
GetRetryMessages returns all task messages in the retry queue.
func GetScheduledMessages ¶
func GetScheduledMessages(tb testing.TB, r *redis.Client) []*base.TaskMessage
GetScheduledMessages returns all task messages in the scheduled queue.
func MustMarshal ¶
func MustMarshal(tb testing.TB, msg *base.TaskMessage) string
MustMarshal marshals given task message and returns a json string. Calling test will fail if marshaling errors out.
func MustMarshalSlice ¶
func MustMarshalSlice(tb testing.TB, msgs []*base.TaskMessage) []string
MustMarshalSlice marshals a slice of task messages and return a slice of json strings. Calling test will fail if marshaling errors out.
func MustUnmarshal ¶
func MustUnmarshal(tb testing.TB, data string) *base.TaskMessage
MustUnmarshal unmarshals given string into task message struct. Calling test will fail if unmarshaling errors out.
func MustUnmarshalSlice ¶
func MustUnmarshalSlice(tb testing.TB, data []string) []*base.TaskMessage
MustUnmarshalSlice unmarshals a slice of strings into a slice of task message structs. Calling test will fail if marshaling errors out.
func NewTaskMessage ¶
func NewTaskMessage(taskType string, payload map[string]interface{}) *base.TaskMessage
NewTaskMessage returns a new instance of TaskMessage given a task type and payload.
func NewTaskMessageWithQueue ¶
func NewTaskMessageWithQueue(taskType string, payload map[string]interface{}, qname string) *base.TaskMessage
NewTaskMessageWithQueue returns a new instance of TaskMessage given a task type, payload and queue name.
func SeedDeadQueue ¶
SeedDeadQueue initializes the dead queue with the given messages.
func SeedEnqueuedQueue ¶
func SeedEnqueuedQueue(tb testing.TB, r *redis.Client, msgs []*base.TaskMessage, queueOpt ...string)
SeedEnqueuedQueue initializes the specified queue with the given messages.
If queue name option is not passed, it defaults to the default queue.
func SeedInProgressQueue ¶
func SeedInProgressQueue(tb testing.TB, r *redis.Client, msgs []*base.TaskMessage)
SeedInProgressQueue initializes the in-progress queue with the given messages.
func SeedRetryQueue ¶
SeedRetryQueue initializes the retry queue with the given messages.
func SeedScheduledQueue ¶
SeedScheduledQueue initializes the scheduled queue with the given messages.
Types ¶
type ZSetEntry ¶
type ZSetEntry struct { Msg *base.TaskMessage Score float64 }
ZSetEntry is an entry in redis sorted set.
func GetDeadEntries ¶
GetDeadEntries returns all task messages and its score in the dead queue.
func GetRetryEntries ¶
GetRetryEntries returns all task messages and its score in the retry queue.
func GetScheduledEntries ¶
GetScheduledEntries returns all task messages and its score in the scheduled queue.