2
0
mirror of https://github.com/hibiken/asynq.git synced 2024-12-26 07:42:17 +08:00

Rename Inspector.CurrentStats to GetQueueInfo

This commit is contained in:
Ken Hibino 2021-05-22 12:13:19 -07:00
parent 8ee1825e67
commit b358de907e
2 changed files with 12 additions and 12 deletions

View File

@ -44,8 +44,8 @@ func (i *Inspector) Queues() ([]string, error) {
return i.rdb.AllQueues()
}
// QueueStats represents a state of queues at a certain time.
type QueueStats struct {
// QueueInfo represents a state of queues at a certain time.
type QueueInfo struct {
// Name of the queue.
Queue string
// Total number of bytes that the queue and its tasks require to be stored in redis.
@ -75,8 +75,8 @@ type QueueStats struct {
Timestamp time.Time
}
// CurrentStats returns a current stats of the given queue.
func (i *Inspector) CurrentStats(qname string) (*QueueStats, error) {
// GetQueueInfo returns current information of the given queue.
func (i *Inspector) GetQueueInfo(qname string) (*QueueInfo, error) {
if err := base.ValidateQueueName(qname); err != nil {
return nil, err
}
@ -84,7 +84,7 @@ func (i *Inspector) CurrentStats(qname string) (*QueueStats, error) {
if err != nil {
return nil, err
}
return &QueueStats{
return &QueueInfo{
Queue: stats.Queue,
MemoryUsage: stats.MemoryUsage,
Size: stats.Size,

View File

@ -254,7 +254,7 @@ func TestInspectorDeleteQueueErrorQueueNotFound(t *testing.T) {
}
}
func TestInspectorCurrentStats(t *testing.T) {
func TestInspectorGetQueueInfo(t *testing.T) {
r := setup(t)
defer r.Close()
m1 := h.NewTaskMessage("task1", nil)
@ -265,7 +265,7 @@ func TestInspectorCurrentStats(t *testing.T) {
m6 := h.NewTaskMessageWithQueue("task6", nil, "low")
now := time.Now()
timeCmpOpt := cmpopts.EquateApproxTime(time.Second)
ignoreMemUsg := cmpopts.IgnoreFields(QueueStats{}, "MemoryUsage")
ignoreMemUsg := cmpopts.IgnoreFields(QueueInfo{}, "MemoryUsage")
inspector := NewInspector(getRedisConnOpt(t))
@ -278,7 +278,7 @@ func TestInspectorCurrentStats(t *testing.T) {
processed map[string]int
failed map[string]int
qname string
want *QueueStats
want *QueueInfo
}{
{
pending: map[string][]*base.TaskMessage{
@ -320,7 +320,7 @@ func TestInspectorCurrentStats(t *testing.T) {
"low": 5,
},
qname: "default",
want: &QueueStats{
want: &QueueInfo{
Queue: "default",
Size: 4,
Pending: 1,
@ -352,14 +352,14 @@ func TestInspectorCurrentStats(t *testing.T) {
r.Set(failedKey, n, 0)
}
got, err := inspector.CurrentStats(tc.qname)
got, err := inspector.GetQueueInfo(tc.qname)
if err != nil {
t.Errorf("r.CurrentStats(%q) = %v, %v, want %v, nil",
t.Errorf("r.GetQueueInfo(%q) = %v, %v, want %v, nil",
tc.qname, got, err, tc.want)
continue
}
if diff := cmp.Diff(tc.want, got, timeCmpOpt, ignoreMemUsg); diff != "" {
t.Errorf("r.CurrentStats(%q) = %v, %v, want %v, nil; (-want, +got)\n%s",
t.Errorf("r.GetQueueInfo(%q) = %v, %v, want %v, nil; (-want, +got)\n%s",
tc.qname, got, err, tc.want, diff)
continue
}