chore: rename gorush to notify package (#609)
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/appleboy/gorush/gorush"
|
||||
"github.com/appleboy/gorush/notify"
|
||||
"github.com/appleboy/gorush/queue"
|
||||
|
||||
"github.com/nsqio/go-nsq"
|
||||
@@ -77,11 +77,11 @@ func NewWorker(opts ...Option) *Worker {
|
||||
// In this case, a message with an empty body is simply ignored/discarded.
|
||||
return nil
|
||||
}
|
||||
var notification *gorush.PushNotification
|
||||
var notification *notify.PushNotification
|
||||
if err := json.Unmarshal(msg.Body, ¬ification); err != nil {
|
||||
return err
|
||||
}
|
||||
gorush.SendNotification(notification)
|
||||
notify.SendNotification(notification)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"errors"
|
||||
"runtime"
|
||||
|
||||
"github.com/appleboy/gorush/gorush"
|
||||
"github.com/appleboy/gorush/notify"
|
||||
"github.com/appleboy/gorush/queue"
|
||||
)
|
||||
|
||||
@@ -84,7 +84,7 @@ func NewWorker(opts ...Option) *Worker {
|
||||
w := &Worker{
|
||||
queueNotification: make(chan queue.QueuedMessage, runtime.NumCPU()<<1),
|
||||
runFunc: func(msg queue.QueuedMessage) error {
|
||||
gorush.SendNotification(msg)
|
||||
notify.SendNotification(msg)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/appleboy/gorush/gorush"
|
||||
"github.com/appleboy/gorush/logx"
|
||||
"github.com/appleboy/gorush/notify"
|
||||
"github.com/appleboy/gorush/queue"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -29,7 +29,7 @@ func TestQueueUsage(t *testing.T) {
|
||||
assert.Equal(t, runtime.NumCPU()<<1, w.Capacity())
|
||||
assert.Equal(t, 0, w.Usage())
|
||||
|
||||
w.Queue(&gorush.PushNotification{})
|
||||
w.Queue(¬ify.PushNotification{})
|
||||
assert.Equal(t, 1, w.Usage())
|
||||
}
|
||||
|
||||
@@ -38,14 +38,14 @@ func TestMaxCapacity(t *testing.T) {
|
||||
assert.Equal(t, 2, w.Capacity())
|
||||
assert.Equal(t, 0, w.Usage())
|
||||
|
||||
assert.NoError(t, w.Queue(&gorush.PushNotification{}))
|
||||
assert.NoError(t, w.Queue(¬ify.PushNotification{}))
|
||||
assert.Equal(t, 1, w.Usage())
|
||||
assert.NoError(t, w.Queue(&gorush.PushNotification{}))
|
||||
assert.NoError(t, w.Queue(¬ify.PushNotification{}))
|
||||
assert.Equal(t, 2, w.Usage())
|
||||
assert.Error(t, w.Queue(&gorush.PushNotification{}))
|
||||
assert.Error(t, w.Queue(¬ify.PushNotification{}))
|
||||
assert.Equal(t, 2, w.Usage())
|
||||
|
||||
err := w.Queue(&gorush.PushNotification{})
|
||||
err := w.Queue(¬ify.PushNotification{})
|
||||
assert.Equal(t, errMaxCapacity, err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user