Skip to content

Commit 0d72ae2

Browse files
committed
fix: testing
Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent 51bf7b9 commit 0d72ae2

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

queue_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func TestWorkerPanic(t *testing.T) {
100100
}
101101
q, err := NewQueue(
102102
WithWorker(w),
103-
WithWorkerCount(2),
103+
WithWorkerCount(5),
104104
)
105105
assert.NoError(t, err)
106106
assert.NotNil(t, q)
@@ -116,7 +116,7 @@ func TestWorkerPanic(t *testing.T) {
116116
}))
117117
q.Start()
118118
time.Sleep(100 * time.Millisecond)
119-
assert.Equal(t, 2, q.Workers())
119+
assert.Equal(t, 5, q.Workers())
120120
q.Shutdown()
121121
q.Wait()
122122
assert.Equal(t, 0, q.Workers())

worker.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,19 @@ import (
88

99
// Worker interface
1010
type Worker interface {
11+
// BeforeRun is called before starting the worker
1112
BeforeRun() error
13+
// Run is called to start the worker
1214
Run(chan struct{}) error
15+
// BeforeRun is called after starting the worker
1316
AfterRun() error
17+
// Shutdown is called if stop all worker
1418
Shutdown() error
19+
// Queue to send message in Queue (single channel, NSQ or AWS SQS)
1520
Queue(job QueuedMessage) error
21+
// Capacity queue capacity = cap(channel name)
1622
Capacity() int
23+
// Usage is how many message in queue
1724
Usage() int
1825
}
1926

@@ -49,7 +56,7 @@ func (w *queueWorker) Run(chan struct{}) error {
4956
if string(msg.Bytes()) == "panic" {
5057
panic("show panic")
5158
}
52-
time.Sleep(100 * time.Millisecond)
59+
time.Sleep(20 * time.Millisecond)
5360
}
5461
return nil
5562
}

0 commit comments

Comments
 (0)