()
| 2204 | } |
| 2205 | |
| 2206 | func (w *natsWriter) flush() error { |
| 2207 | // If a pending buffer is set, we don't flush. Code that needs to |
| 2208 | // write directly to the socket, by-passing buffers during (re)connect, |
| 2209 | // will use the writeDirect() API. |
| 2210 | if w.pending != nil { |
| 2211 | return nil |
| 2212 | } |
| 2213 | // Do not skip calling w.w.Write() here if len(w.bufs) is 0 because |
| 2214 | // the actual writer (if websocket for instance) may have things |
| 2215 | // to do such as sending control frames, etc.. |
| 2216 | _, err := w.w.Write(w.bufs) |
| 2217 | w.bufs = w.bufs[:0] |
| 2218 | return err |
| 2219 | } |
| 2220 | |
| 2221 | func (w *natsWriter) buffered() int { |
| 2222 | if w.pending != nil { |
no test coverage detected