// write is used to do a PUT request against an endpoint
// and serialize/deserialized using the standard Consul conventions.
556961
func (c *Client) write(endpoint string, in, out interface{}, q *WriteOptions) (*WriteMeta, error) {
	r := c.newRequest("PUT", endpoint)
	r.setWriteOptions(q)
	r.obj = in
	rtt, resp, err := requireOK(c.doRequest(r))
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	wm := &WriteMeta{RequestTime: rtt}
	if out != nil {
		if err := decodeBody(resp, &out); err != nil {
			return nil, err
		}
	} else if _, err := ioutil.ReadAll(resp.Body); err != nil {
		return nil, err
	}
	return wm, nil
}
510138
func (c *Client) Write(ctx context.Context, points []chronograf.Point) error {
	if !c.opened {
		return chronograf.ErrUninitialized
	}
	return c.nextDataNode().Write(ctx, points)
}
1065079
func (s *CfgServiceLBState) Write() error {
	key := fmt.Sprintf(serviceLBConfigPath, s.ID)
	err := s.StateDriver.WriteState(key, s, json.Marshal)
	return err
}
1304456
func (w *appResponseWriter) Write(data []byte) (n int, err error) {
	if w.statusCode == 0 {
		w.statusCode = http.StatusOK
	}
	size, err := w.ResponseWriter.Write(data)
	w.size += size
	return size, err
}
22504
func (this *statusResponseWriter) Write(data []byte) (int, error) {
	if this.code == 0 {
		this.code = http.StatusOK
	}
	return this.ResponseWriter.Write(data)
}
929335
func (w *ResponseWriter) Write(p []byte) (int, error) {
	return w.w.Write(p)
}
6376
func (this *BufferedWriter) Write(p []byte) (n int, err error) {

	dst := make([]byte, len(p), len(p))
	copy(dst, p)

	select {
	case this.queue <- dst:
		return len(dst), nil
	default:
		return 0, BufferFull
	}
}
927164
func (w *ResponseWriter) Write(data []byte) (int, error) {
	size, err := w.ResponseWriter.Write(data)
	w.size += size
	return size, err
}
390944
func (r *responseWriter) Write(b []byte) (int, error) {
	if r.buf == nil {
		return 0, ErrReqNotSupp
	}
	if len(b) > r.buf.Cap()-r.buf.Len() {
		return 0, io.ErrShortWrite
	}

	return r.buf.Write(b)
}
423950
func (r *reopenWriter) Write(p []byte) (n int, err error) {
	r.lock.Lock()
	defer r.lock.Unlock()
	if r.lastErr != nil {
		err = fmt.Errorf("unusable due to %v", r.lastErr)
		return
	}
	return r.writer.Write(p)
}
496207
func (h *JSONWriter) Write(w http.ResponseWriter, r *http.Request, e interface{}) {
	h.WriteCode(w, r, http.StatusOK, e)
}
965662
func (w *BufferedWriter) Write(p []byte) (int, error) {
	if w.err != nil {
		return 0, w.err
	}

	_, w.err = w.bw.Write(p)
	if w.err != nil {
		return 0, w.err
	}

	return len(p), nil
}
790615
func (r *Response) Write(b []byte) (n int, err error) {
	if !r.Committed {
		r.WriteHeader(http.StatusOK)
	}
	n, err = r.Writer.Write(b)
	r.Size += int64(n)
	for _, fn := range r.afterFuncs {
		fn()
	}
	return
}
955191
func (c *conn) Write(w pdu.Body) error {
	var b bytes.Buffer
	err := w.SerializeTo(&b)
	if err != nil {
		return err
	}
	_, err = io.Copy(c.w, &b)
	if err != nil {
		return err
	}
	return c.w.Flush()
}
221053
func (c *jsonCodec) Write(ctx context.Context, v interface{}) error {
	c.encMu.Lock()
	defer c.encMu.Unlock()

	deadline, ok := ctx.Deadline()
	if !ok {
		deadline = time.Now().Add(defaultWriteTimeout)
	}
	c.conn.SetWriteDeadline(deadline)
	return c.encode(v)
}
1344124
func (r *ResponseFilterWriter) Write(b []byte) (int, error) {
	if !r.statusCodeWritten {
		r.WriteHeader(http.StatusOK)
	}
	if r.shouldCompress {
		return r.gzipResponseWriter.Write(b)
	}
	return r.ResponseWriter.Write(b)
}
624109
func (w *Writer) Write(b []byte) (int, error) {
	n := len(b)
	end := len(w.buf)
	if end+n > cap(w.buf) {
		buf := make([]byte, end, 2*cap(w.buf)+n)
		copy(buf, w.buf)
		w.buf = buf
	}
	w.buf = w.buf[:end+n]
	return copy(w.buf[end:], b), nil
}