You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
581 B
Go
32 lines
581 B
Go
package queue
|
|
|
|
import "github.com/tal-tech/go-zero/core/errorx"
|
|
|
|
type MultiQueuePusher struct {
|
|
name string
|
|
pushers []Pusher
|
|
}
|
|
|
|
func NewMultiQueuePusher(pushers []Pusher) Pusher {
|
|
return &MultiQueuePusher{
|
|
name: generateName(pushers),
|
|
pushers: pushers,
|
|
}
|
|
}
|
|
|
|
func (pusher *MultiQueuePusher) Name() string {
|
|
return pusher.name
|
|
}
|
|
|
|
func (pusher *MultiQueuePusher) Push(message string) error {
|
|
var batchError errorx.BatchError
|
|
|
|
for _, each := range pusher.pushers {
|
|
if err := each.Push(message); err != nil {
|
|
batchError.Add(err)
|
|
}
|
|
}
|
|
|
|
return batchError.Err()
|
|
}
|