mirror of https://bitbucket.org/ausocean/av.git
revid: fixed multiSender sending and handling of send fails
This commit is contained in:
parent
85401c8df4
commit
48c7a1f21d
|
@ -70,28 +70,36 @@ func newMultiSender(owner *Revid, senders []loadSender) *multiSender {
|
|||
func (s *multiSender) Write(d []byte) (int, error) {
|
||||
for i, sender := range s.senders {
|
||||
sender.load(d)
|
||||
s.owner.config.Logger.Log(logger.Debug, "sending to output", "output", i)
|
||||
err := sender.send()
|
||||
if err != nil {
|
||||
s.owner.config.Logger.Log(logger.Warning, "send failed", "output", i, "error", err)
|
||||
s.handleFail(sender, err)
|
||||
for s.owner.config.SendRetry {
|
||||
if !s.owner.IsRunning() {
|
||||
sender.release()
|
||||
return 0, err
|
||||
}
|
||||
if s.owner.config.SendRetry {
|
||||
for err != nil {
|
||||
s.owner.config.Logger.Log(logger.Warning, "send failed", "output", i, "error", err)
|
||||
err = sender.handleSendFail(err)
|
||||
if err != nil {
|
||||
s.owner.config.Logger.Log(logger.Warning, "could not currenty handle send fail", "output", i, "error", err)
|
||||
continue
|
||||
}
|
||||
err = sender.send()
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
s.handleFail(sender, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
sender.release()
|
||||
}
|
||||
return len(d), nil
|
||||
}
|
||||
|
||||
// handleFail calls the passed sender's handleSendFail method and then logs
|
||||
// error if this was not successful.
|
||||
func (s *multiSender) handleFail(sender loadSender, e error) {
|
||||
err := sender.handleSendFail(e)
|
||||
if err != nil {
|
||||
s.owner.config.Logger.Log(logger.Warning, "could not currenty handle send fail", "error", err)
|
||||
}
|
||||
}
|
||||
|
||||
// minimalHttpSender implements Sender for posting HTTP to netreceiver or vidgrind.
|
||||
type minimalHttpSender struct {
|
||||
client *netsender.Sender
|
||||
|
|
Loading…
Reference in New Issue