refactor names

master
kevin 4 years ago
parent 4bdf5e4c90
commit 4b636cd293

@ -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++ {

@ -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"))
}

@ -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 {

@ -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++ {
Loading…
Cancel
Save