@@ -18,7 +18,7 @@ import (
18
18
)
19
19
20
20
func TestMaxCapacity (t * testing.T ) {
21
- w := NewConsumer (WithQueueSize (2 ))
21
+ w := NewRing (WithQueueSize (2 ))
22
22
23
23
assert .NoError (t , w .Queue (& mockMessage {}))
24
24
assert .NoError (t , w .Queue (& mockMessage {}))
@@ -32,7 +32,7 @@ func TestCustomFuncAndWait(t *testing.T) {
32
32
m := mockMessage {
33
33
message : "foo" ,
34
34
}
35
- w := NewConsumer (
35
+ w := NewRing (
36
36
WithFn (func (ctx context.Context , m core.QueuedMessage ) error {
37
37
time .Sleep (500 * time .Millisecond )
38
38
return nil
@@ -61,7 +61,7 @@ func TestEnqueueJobAfterShutdown(t *testing.T) {
61
61
m := mockMessage {
62
62
message : "foo" ,
63
63
}
64
- w := NewConsumer ()
64
+ w := NewRing ()
65
65
q , err := NewQueue (
66
66
WithWorker (w ),
67
67
WithWorkerCount (2 ),
@@ -81,7 +81,7 @@ func TestJobReachTimeout(t *testing.T) {
81
81
m := mockMessage {
82
82
message : "foo" ,
83
83
}
84
- w := NewConsumer (
84
+ w := NewRing (
85
85
WithFn (func (ctx context.Context , m core.QueuedMessage ) error {
86
86
for {
87
87
select {
@@ -114,7 +114,7 @@ func TestCancelJobAfterShutdown(t *testing.T) {
114
114
m := mockMessage {
115
115
message : "foo" ,
116
116
}
117
- w := NewConsumer (
117
+ w := NewRing (
118
118
WithLogger (NewEmptyLogger ()),
119
119
WithFn (func (ctx context.Context , m core.QueuedMessage ) error {
120
120
for {
@@ -147,7 +147,7 @@ func TestCancelJobAfterShutdown(t *testing.T) {
147
147
}
148
148
149
149
func TestGoroutineLeak (t * testing.T ) {
150
- w := NewConsumer (
150
+ w := NewRing (
151
151
WithLogger (NewLogger ()),
152
152
WithFn (func (ctx context.Context , m core.QueuedMessage ) error {
153
153
for {
@@ -191,7 +191,7 @@ func TestGoroutinePanic(t *testing.T) {
191
191
m := mockMessage {
192
192
message : "foo" ,
193
193
}
194
- w := NewConsumer (
194
+ w := NewRing (
195
195
WithFn (func (ctx context.Context , m core.QueuedMessage ) error {
196
196
panic ("missing something" )
197
197
}),
@@ -208,7 +208,7 @@ func TestGoroutinePanic(t *testing.T) {
208
208
}
209
209
210
210
func TestIncreaseWorkerCount (t * testing.T ) {
211
- w := NewConsumer (
211
+ w := NewRing (
212
212
WithLogger (NewEmptyLogger ()),
213
213
WithFn (func (ctx context.Context , m core.QueuedMessage ) error {
214
214
time .Sleep (500 * time .Millisecond )
@@ -239,7 +239,7 @@ func TestIncreaseWorkerCount(t *testing.T) {
239
239
}
240
240
241
241
func TestDecreaseWorkerCount (t * testing.T ) {
242
- w := NewConsumer (
242
+ w := NewRing (
243
243
WithFn (func (ctx context.Context , m core.QueuedMessage ) error {
244
244
time .Sleep (100 * time .Millisecond )
245
245
return nil
@@ -270,13 +270,13 @@ func TestDecreaseWorkerCount(t *testing.T) {
270
270
q .Release ()
271
271
}
272
272
273
- func TestHandleAllJobBeforeShutdownConsumer (t * testing.T ) {
273
+ func TestHandleAllJobBeforeShutdownRing (t * testing.T ) {
274
274
controller := gomock .NewController (t )
275
275
defer controller .Finish ()
276
276
277
277
m := mocks .NewMockQueuedMessage (controller )
278
278
279
- w := NewConsumer (
279
+ w := NewRing (
280
280
WithFn (func (ctx context.Context , m core.QueuedMessage ) error {
281
281
time .Sleep (10 * time .Millisecond )
282
282
return nil
@@ -303,7 +303,7 @@ func TestHandleAllJobBeforeShutdownConsumer(t *testing.T) {
303
303
<- done
304
304
}
305
305
306
- func TestHandleAllJobBeforeShutdownConsumerInQueue (t * testing.T ) {
306
+ func TestHandleAllJobBeforeShutdownRingInQueue (t * testing.T ) {
307
307
controller := gomock .NewController (t )
308
308
defer controller .Finish ()
309
309
@@ -312,7 +312,7 @@ func TestHandleAllJobBeforeShutdownConsumerInQueue(t *testing.T) {
312
312
313
313
messages := make (chan string , 10 )
314
314
315
- w := NewConsumer (
315
+ w := NewRing (
316
316
WithFn (func (ctx context.Context , m core.QueuedMessage ) error {
317
317
time .Sleep (10 * time .Millisecond )
318
318
messages <- string (m .Bytes ())
@@ -346,7 +346,7 @@ func TestRetryCountWithNewMessage(t *testing.T) {
346
346
keep := make (chan struct {})
347
347
count := 1
348
348
349
- w := NewConsumer (
349
+ w := NewRing (
350
350
WithFn (func (ctx context.Context , m core.QueuedMessage ) error {
351
351
if count % 3 != 0 {
352
352
count ++
@@ -384,7 +384,7 @@ func TestRetryCountWithNewTask(t *testing.T) {
384
384
messages := make (chan string , 10 )
385
385
count := 1
386
386
387
- w := NewConsumer ()
387
+ w := NewRing ()
388
388
389
389
q , err := NewQueue (
390
390
WithLogger (NewLogger ()),
@@ -422,7 +422,7 @@ func TestCancelRetryCountWithNewTask(t *testing.T) {
422
422
messages := make (chan string , 10 )
423
423
count := 1
424
424
425
- w := NewConsumer ()
425
+ w := NewRing ()
426
426
427
427
q , err := NewQueue (
428
428
WithLogger (NewLogger ()),
@@ -464,7 +464,7 @@ func TestCancelRetryCountWithNewMessage(t *testing.T) {
464
464
messages := make (chan string , 10 )
465
465
count := 1
466
466
467
- w := NewConsumer (
467
+ w := NewRing (
468
468
WithFn (func (ctx context.Context , m core.QueuedMessage ) error {
469
469
if count % 3 != 0 {
470
470
count ++
@@ -498,7 +498,7 @@ func TestCancelRetryCountWithNewMessage(t *testing.T) {
498
498
}
499
499
500
500
func TestErrNoTaskInQueue (t * testing.T ) {
501
- w := NewConsumer (
501
+ w := NewRing (
502
502
WithFn (func (ctx context.Context , m core.QueuedMessage ) error {
503
503
return nil
504
504
}),
0 commit comments