mirror of https://bitbucket.org/ausocean/av.git
revid: simplified multiSender Write method
This commit is contained in:
parent
1c75867ba5
commit
30ea5d74f6
|
@ -57,6 +57,7 @@ type Sender interface {
|
||||||
type multiSender struct {
|
type multiSender struct {
|
||||||
owner *Revid
|
owner *Revid
|
||||||
senders []loadSender
|
senders []loadSender
|
||||||
|
retry bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// newMultiSender returns a pointer to a new multiSender.
|
// newMultiSender returns a pointer to a new multiSender.
|
||||||
|
@ -69,28 +70,23 @@ func newMultiSender(owner *Revid, senders []loadSender) *multiSender {
|
||||||
// sends we notify the current sender to take any required actions and then try
|
// sends we notify the current sender to take any required actions and then try
|
||||||
// the send again.
|
// the send again.
|
||||||
func (s *multiSender) Write(d []byte) (int, error) {
|
func (s *multiSender) Write(d []byte) (int, error) {
|
||||||
for i, sender := range s.senders {
|
for _, sender := range s.senders {
|
||||||
sender.load(d)
|
sender.load(d)
|
||||||
err := sender.send()
|
for s.owner.IsRunning() {
|
||||||
if err != nil {
|
err := sender.send()
|
||||||
s.owner.config.Logger.Log(logger.Warning, "send failed", "output", i, "error", err)
|
if err != nil {
|
||||||
s.handleFail(sender, err)
|
s.handleFail(sender, err)
|
||||||
if s.owner.config.SendRetry {
|
}
|
||||||
for {
|
if err == nil || !s.retry {
|
||||||
if !s.owner.IsRunning() {
|
break
|
||||||
sender.release()
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
err = sender.send()
|
|
||||||
if err == nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
s.handleFail(sender, err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, sender := range s.senders {
|
||||||
sender.release()
|
sender.release()
|
||||||
}
|
}
|
||||||
|
|
||||||
return len(d), nil
|
return len(d), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue