Shouldn't it continue when failed to decode a msg when consuming from the input protobuf stream
fivesheep opened this issue · comments
For this piece of code, when dec.ReadMsg has error and the error is not io.EOF, shall it skip to the next iteration with continue
after the line a new decoder was created?
https://github.com/cpuguy83/docker-log-driver-test/blob/master/driver.go#L95-L102
for {
if err := dec.ReadMsg(&buf); err != nil {
if err == io.EOF {
logrus.WithField("id", lf.info.ContainerID).WithError(err).Debug("shutting down log logger")
lf.stream.Close()
return
}
dec = protoio.NewUint32DelimitedReader(lf.stream, binary.BigEndian, 1e6)
}
var msg logger.Message
msg.Line = buf.Line
msg.Source = buf.Source
msg.Partial = buf.Partial
msg.Timestamp = time.Unix(0, buf.TimeNano)
if err := lf.l.Log(&msg); err != nil {
logrus.WithField("id", lf.info.ContainerID).WithError(err).WithField("message", msg).Error("error writing log message")
continue
}
buf.Reset()
}
Indeed it should.