revid: sending encode errors to errorHandler and made multiSender smarter

Errors captured from encoding are now sent to the error handler.
We also made multiSender smart so that during a write if sendRetry is on, we first check
that revid is actually running before attempting to send again. If revid is not running we return.
We also now log any send errors inside multiSender.
This commit is contained in:
Saxon 2019-03-10 12:34:45 +10:30
parent fc72eeaa0f
commit def220daf3
2 changed files with 8 additions and 4 deletions

View File

@ -450,16 +450,16 @@ loop:
// Get bytes from the chunk.
bytes := chunk.Bytes()
// Loop over encoders and hand bytes over to each one.
for _, enc := range r.encoder {
err := enc.Encode(bytes)
if err != nil {
fmt.Printf("encode error: %v", err)
// TODO: deal with this error
r.err <- err
}
}
// Release the chunk back to the ring buffer
// Release the chunk back to the ring buffer.
chunk.Close()
// FIXME(saxon): this doesn't work anymore.

View File

@ -70,11 +70,15 @@ 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, fmt.Sprintf("sending to output: %d", i))
s.owner.config.Logger.Log(logger.Debug, "sending to output", "output", i)
err := sender.send()
if err != nil {
if !s.owner.IsRunning() {
return 0, err
}
if s.owner.config.SendRetry {
for err != nil {
s.owner.config.Logger.Log(logger.Warning, "send failed", "output", i, "error", err)
sender.handleSendFail(err)
err = sender.send()
}