File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ func TestWorkerPanic(t *testing.T) {
100
100
}
101
101
q , err := NewQueue (
102
102
WithWorker (w ),
103
- WithWorkerCount (2 ),
103
+ WithWorkerCount (5 ),
104
104
)
105
105
assert .NoError (t , err )
106
106
assert .NotNil (t , q )
@@ -116,7 +116,7 @@ func TestWorkerPanic(t *testing.T) {
116
116
}))
117
117
q .Start ()
118
118
time .Sleep (100 * time .Millisecond )
119
- assert .Equal (t , 2 , q .Workers ())
119
+ assert .Equal (t , 5 , q .Workers ())
120
120
q .Shutdown ()
121
121
q .Wait ()
122
122
assert .Equal (t , 0 , q .Workers ())
Original file line number Diff line number Diff line change @@ -8,12 +8,19 @@ import (
8
8
9
9
// Worker interface
10
10
type Worker interface {
11
+ // BeforeRun is called before starting the worker
11
12
BeforeRun () error
13
+ // Run is called to start the worker
12
14
Run (chan struct {}) error
15
+ // BeforeRun is called after starting the worker
13
16
AfterRun () error
17
+ // Shutdown is called if stop all worker
14
18
Shutdown () error
19
+ // Queue to send message in Queue (single channel, NSQ or AWS SQS)
15
20
Queue (job QueuedMessage ) error
21
+ // Capacity queue capacity = cap(channel name)
16
22
Capacity () int
23
+ // Usage is how many message in queue
17
24
Usage () int
18
25
}
19
26
@@ -49,7 +56,7 @@ func (w *queueWorker) Run(chan struct{}) error {
49
56
if string (msg .Bytes ()) == "panic" {
50
57
panic ("show panic" )
51
58
}
52
- time .Sleep (100 * time .Millisecond )
59
+ time .Sleep (20 * time .Millisecond )
53
60
}
54
61
return nil
55
62
}
You can’t perform that action at this time.
0 commit comments