@@ -22,7 +22,7 @@ func TestQueueUsage(t *testing.T) {
2222}
2323
2424func TestMaxCapacity (t * testing.T ) {
25- w := NewConsumer (WithConsumerQueueNum (2 ))
25+ w := NewConsumer (WithQueueSize (2 ))
2626 assert .Equal (t , 2 , w .Capacity ())
2727 assert .Equal (t , 0 , w .Usage ())
2828
@@ -42,7 +42,7 @@ func TestCustomFuncAndWait(t *testing.T) {
4242 message : "foo" ,
4343 }
4444 w := NewConsumer (
45- WithConsumerRunFunc (func (ctx context.Context , m QueuedMessage ) error {
45+ WithFn (func (ctx context.Context , m QueuedMessage ) error {
4646 time .Sleep (500 * time .Millisecond )
4747 return nil
4848 }),
@@ -109,7 +109,7 @@ func TestJobReachTimeout(t *testing.T) {
109109 message : "foo" ,
110110 }
111111 w := NewConsumer (
112- WithConsumerRunFunc (func (ctx context.Context , m QueuedMessage ) error {
112+ WithFn (func (ctx context.Context , m QueuedMessage ) error {
113113 for {
114114 select {
115115 case <- ctx .Done ():
@@ -144,8 +144,8 @@ func TestCancelJobAfterShutdown(t *testing.T) {
144144 message : "foo" ,
145145 }
146146 w := NewConsumer (
147- WithConsumerLogger (NewEmptyLogger ()),
148- WithConsumerRunFunc (func (ctx context.Context , m QueuedMessage ) error {
147+ WithLogger (NewEmptyLogger ()),
148+ WithFn (func (ctx context.Context , m QueuedMessage ) error {
149149 for {
150150 select {
151151 case <- ctx .Done ():
@@ -179,8 +179,8 @@ func TestGoroutineLeak(t *testing.T) {
179179 message : "foo" ,
180180 }
181181 w := NewConsumer (
182- WithConsumerLogger (NewEmptyLogger ()),
183- WithConsumerRunFunc (func (ctx context.Context , m QueuedMessage ) error {
182+ WithLogger (NewEmptyLogger ()),
183+ WithFn (func (ctx context.Context , m QueuedMessage ) error {
184184 for {
185185 select {
186186 case <- ctx .Done ():
@@ -222,7 +222,7 @@ func TestGoroutinePanic(t *testing.T) {
222222 message : "foo" ,
223223 }
224224 w := NewConsumer (
225- WithConsumerRunFunc (func (ctx context.Context , m QueuedMessage ) error {
225+ WithFn (func (ctx context.Context , m QueuedMessage ) error {
226226 panic ("missing something" )
227227 }),
228228 )
@@ -245,7 +245,7 @@ func TestHandleTimeout(t *testing.T) {
245245 Body : []byte ("foo" ),
246246 }
247247 w := NewConsumer (
248- WithConsumerRunFunc (func (ctx context.Context , m QueuedMessage ) error {
248+ WithFn (func (ctx context.Context , m QueuedMessage ) error {
249249 time .Sleep (200 * time .Millisecond )
250250 return nil
251251 }),
@@ -261,7 +261,7 @@ func TestHandleTimeout(t *testing.T) {
261261 }
262262
263263 w = NewConsumer (
264- WithConsumerRunFunc (func (ctx context.Context , m QueuedMessage ) error {
264+ WithFn (func (ctx context.Context , m QueuedMessage ) error {
265265 time .Sleep (200 * time .Millisecond )
266266 return nil
267267 }),
@@ -285,7 +285,7 @@ func TestJobComplete(t *testing.T) {
285285 Body : []byte ("foo" ),
286286 }
287287 w := NewConsumer (
288- WithConsumerRunFunc (func (ctx context.Context , m QueuedMessage ) error {
288+ WithFn (func (ctx context.Context , m QueuedMessage ) error {
289289 return errors .New ("job completed" )
290290 }),
291291 )
@@ -300,7 +300,7 @@ func TestJobComplete(t *testing.T) {
300300 }
301301
302302 w = NewConsumer (
303- WithConsumerRunFunc (func (ctx context.Context , m QueuedMessage ) error {
303+ WithFn (func (ctx context.Context , m QueuedMessage ) error {
304304 time .Sleep (200 * time .Millisecond )
305305 return errors .New ("job completed" )
306306 }),
0 commit comments