chore(queue): add custom logger.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2021-07-24 11:11:13 +08:00
parent a210abd323
commit fcfa195bc6
1 changed files with 8 additions and 0 deletions

View File

@ -94,6 +94,9 @@ func TestShutDonwPanic(t *testing.T) {
}
func TestWorkersNum(t *testing.T) {
m := mockMessage{
msg: "test",
}
w := NewWorker(
WithRunFunc(func(msg queue.QueuedMessage) error {
logx.LogAccess.Infof("get message: %s", msg.Bytes())
@ -104,12 +107,17 @@ func TestWorkersNum(t *testing.T) {
q, err := queue.NewQueue(
queue.WithWorker(w),
queue.WithWorkerCount(2),
queue.WithLogger(logx.LogAccess),
)
assert.NoError(t, err)
q.Start()
q.Start()
q.Start()
q.Start()
q.Queue(m)
q.Queue(m)
q.Queue(m)
q.Queue(m)
time.Sleep(50 * time.Millisecond)
assert.Equal(t, 8, q.Workers())
q.Shutdown()