mirror of
https://github.com/hibiken/asynq.git
synced 2025-10-03 05:12:01 +08:00
Use int as priority value type.
Do not use unsigned int for merely non-negative quantities as it complicates simple arithmetic.
This commit is contained in:
@@ -91,7 +91,7 @@ type TaskMessage struct {
|
||||
type ProcessInfo struct {
|
||||
mu sync.Mutex
|
||||
Concurrency int
|
||||
Queues map[string]uint
|
||||
Queues map[string]int
|
||||
StrictPriority bool
|
||||
PID int
|
||||
Host string
|
||||
@@ -101,7 +101,7 @@ type ProcessInfo struct {
|
||||
}
|
||||
|
||||
// NewProcessInfo returns a new instance of ProcessInfo.
|
||||
func NewProcessInfo(host string, pid, concurrency int, queues map[string]uint, strict bool) *ProcessInfo {
|
||||
func NewProcessInfo(host string, pid, concurrency int, queues map[string]int, strict bool) *ProcessInfo {
|
||||
return &ProcessInfo{
|
||||
Host: host,
|
||||
PID: pid,
|
||||
|
@@ -82,7 +82,7 @@ func TestProcessInfoKey(t *testing.T) {
|
||||
|
||||
// Note: Run this test with -race flag to check for data race.
|
||||
func TestProcessInfoSetter(t *testing.T) {
|
||||
pi := NewProcessInfo("localhost", 1234, 8, map[string]uint{"default": 1}, false)
|
||||
pi := NewProcessInfo("localhost", 1234, 8, map[string]int{"default": 1}, false)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
||||
|
@@ -245,10 +245,10 @@ func reverse(x []string) {
|
||||
// for the list operation.
|
||||
type Pagination struct {
|
||||
// Number of items in the page.
|
||||
Size uint
|
||||
Size int
|
||||
|
||||
// Page number starting from zero.
|
||||
Page uint
|
||||
Page int
|
||||
}
|
||||
|
||||
func (p Pagination) start() int64 {
|
||||
|
@@ -317,8 +317,8 @@ func TestListEnqueuedPagination(t *testing.T) {
|
||||
tests := []struct {
|
||||
desc string
|
||||
qname string
|
||||
page uint
|
||||
size uint
|
||||
page int
|
||||
size int
|
||||
wantSize int
|
||||
wantFirst string
|
||||
wantLast string
|
||||
@@ -418,8 +418,8 @@ func TestListInProgressPagination(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
desc string
|
||||
page uint
|
||||
size uint
|
||||
page int
|
||||
size int
|
||||
wantSize int
|
||||
wantFirst string
|
||||
wantLast string
|
||||
@@ -524,8 +524,8 @@ func TestListScheduledPagination(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
desc string
|
||||
page uint
|
||||
size uint
|
||||
page int
|
||||
size int
|
||||
wantSize int
|
||||
wantFirst string
|
||||
wantLast string
|
||||
@@ -667,8 +667,8 @@ func TestListRetryPagination(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
desc string
|
||||
page uint
|
||||
size uint
|
||||
page int
|
||||
size int
|
||||
wantSize int
|
||||
wantFirst string
|
||||
wantLast string
|
||||
@@ -800,8 +800,8 @@ func TestListDeadPagination(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
desc string
|
||||
page uint
|
||||
size uint
|
||||
page int
|
||||
size int
|
||||
wantSize int
|
||||
wantFirst string
|
||||
wantLast string
|
||||
@@ -2056,7 +2056,7 @@ func TestListProcesses(t *testing.T) {
|
||||
|
||||
ps1 := &base.ProcessInfo{
|
||||
Concurrency: 10,
|
||||
Queues: map[string]uint{"default": 1},
|
||||
Queues: map[string]int{"default": 1},
|
||||
Host: "do.droplet1",
|
||||
PID: 1234,
|
||||
State: "running",
|
||||
@@ -2066,7 +2066,7 @@ func TestListProcesses(t *testing.T) {
|
||||
|
||||
ps2 := &base.ProcessInfo{
|
||||
Concurrency: 20,
|
||||
Queues: map[string]uint{"email": 1},
|
||||
Queues: map[string]int{"email": 1},
|
||||
Host: "do.droplet2",
|
||||
PID: 9876,
|
||||
State: "stopped",
|
||||
|
@@ -745,7 +745,7 @@ func TestReadWriteClearProcessInfo(t *testing.T) {
|
||||
r := setup(t)
|
||||
pinfo := &base.ProcessInfo{
|
||||
Concurrency: 10,
|
||||
Queues: map[string]uint{"default": 2, "email": 5, "low": 1},
|
||||
Queues: map[string]int{"default": 2, "email": 5, "low": 1},
|
||||
PID: 98765,
|
||||
Host: "localhost",
|
||||
State: "running",
|
||||
|
Reference in New Issue
Block a user