diff --git a/core/queue/balancedqueuepusher.go b/core/queue/balancedpusher.go similarity index 71% rename from core/queue/balancedqueuepusher.go rename to core/queue/balancedpusher.go index 1e40cf30..32bc2ba2 100644 --- a/core/queue/balancedqueuepusher.go +++ b/core/queue/balancedpusher.go @@ -9,24 +9,24 @@ import ( var ErrNoAvailablePusher = errors.New("no available pusher") -type BalancedQueuePusher struct { +type BalancedPusher struct { name string pushers []Pusher index uint64 } -func NewBalancedQueuePusher(pushers []Pusher) Pusher { - return &BalancedQueuePusher{ +func NewBalancedPusher(pushers []Pusher) Pusher { + return &BalancedPusher{ name: generateName(pushers), pushers: pushers, } } -func (pusher *BalancedQueuePusher) Name() string { +func (pusher *BalancedPusher) Name() string { return pusher.name } -func (pusher *BalancedQueuePusher) Push(message string) error { +func (pusher *BalancedPusher) Push(message string) error { size := len(pusher.pushers) for i := 0; i < size; i++ { diff --git a/core/queue/balancedqueuepusher_test.go b/core/queue/balancedpusher_test.go similarity index 91% rename from core/queue/balancedqueuepusher_test.go rename to core/queue/balancedpusher_test.go index ff246132..f73c70e9 100644 --- a/core/queue/balancedqueuepusher_test.go +++ b/core/queue/balancedpusher_test.go @@ -20,7 +20,7 @@ func TestBalancedQueuePusher(t *testing.T) { mockedPushers = append(mockedPushers, p) } - pusher := NewBalancedQueuePusher(pushers) + pusher := NewBalancedPusher(pushers) assert.True(t, len(pusher.Name()) > 0) for i := 0; i < numPushers*1000; i++ { @@ -37,7 +37,7 @@ func TestBalancedQueuePusher(t *testing.T) { } func TestBalancedQueuePusher_NoAvailable(t *testing.T) { - pusher := NewBalancedQueuePusher(nil) + pusher := NewBalancedPusher(nil) assert.True(t, len(pusher.Name()) == 0) assert.Equal(t, ErrNoAvailablePusher, pusher.Push("item")) } diff --git a/core/queue/multiqueuepusher.go b/core/queue/multipusher.go similarity index 62% rename from core/queue/multiqueuepusher.go rename to core/queue/multipusher.go index dd811dc1..b9df5c7c 100644 --- a/core/queue/multiqueuepusher.go +++ b/core/queue/multipusher.go @@ -2,23 +2,23 @@ package queue import "github.com/tal-tech/go-zero/core/errorx" -type MultiQueuePusher struct { +type MultiPusher struct { name string pushers []Pusher } -func NewMultiQueuePusher(pushers []Pusher) Pusher { - return &MultiQueuePusher{ +func NewMultiPusher(pushers []Pusher) Pusher { + return &MultiPusher{ name: generateName(pushers), pushers: pushers, } } -func (pusher *MultiQueuePusher) Name() string { +func (pusher *MultiPusher) Name() string { return pusher.name } -func (pusher *MultiQueuePusher) Push(message string) error { +func (pusher *MultiPusher) Push(message string) error { var batchError errorx.BatchError for _, each := range pusher.pushers { diff --git a/core/queue/multiqueuepusher_test.go b/core/queue/multipusher_test.go similarity index 95% rename from core/queue/multiqueuepusher_test.go rename to core/queue/multipusher_test.go index 5721154f..1df2de0c 100644 --- a/core/queue/multiqueuepusher_test.go +++ b/core/queue/multipusher_test.go @@ -21,7 +21,7 @@ func TestMultiQueuePusher(t *testing.T) { mockedPushers = append(mockedPushers, p) } - pusher := NewMultiQueuePusher(pushers) + pusher := NewMultiPusher(pushers) assert.True(t, len(pusher.Name()) > 0) for i := 0; i < 1000; i++ {