func (c *serverConn) loop(w chan<- *tsdb.Point) { statServerCurrEstab.Add(1) defer statServerCurrEstab.Add(-1) defer c.Close() var ( r = ProtocolReader(c) dec = tsdb.NewDecoder(r) ) dec.DisableOrderCheck() for { point, err := dec.Decode() if err != nil { if _, ok := err.(*tsdb.SyntaxError); ok { statErrors.Add("type=Syntax", 1) fmt.Fprintf(c, "error: invalid syntax\n") continue } return } select { case w <- point: // ok default: statErrors.Add("type=Enqueue", 1) w <- point } } }
func newDecoder(r io.Reader, timeout time.Duration) *decoder { d := &decoder{ dec: tsdb.NewDecoder(r), timeout: timeout, timeoutTimer: time.NewTimer(timeout), pointChan: make(chan *tsdb.Point), errChan: make(chan error), } go d.mainloop() return d }