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
556 B
Go
32 lines
556 B
Go
4 years ago
|
package queue
|
||
|
|
||
|
import "github.com/tal-tech/go-zero/core/errorx"
|
||
|
|
||
4 years ago
|
type MultiPusher struct {
|
||
4 years ago
|
name string
|
||
|
pushers []Pusher
|
||
|
}
|
||
|
|
||
4 years ago
|
func NewMultiPusher(pushers []Pusher) Pusher {
|
||
|
return &MultiPusher{
|
||
4 years ago
|
name: generateName(pushers),
|
||
|
pushers: pushers,
|
||
|
}
|
||
|
}
|
||
|
|
||
4 years ago
|
func (pusher *MultiPusher) Name() string {
|
||
4 years ago
|
return pusher.name
|
||
|
}
|
||
|
|
||
4 years ago
|
func (pusher *MultiPusher) Push(message string) error {
|
||
4 years ago
|
var batchError errorx.BatchError
|
||
|
|
||
|
for _, each := range pusher.pushers {
|
||
|
if err := each.Push(message); err != nil {
|
||
|
batchError.Add(err)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return batchError.Err()
|
||
|
}
|