// Write implements the io.Writer interface, adding deadlines
482114
func (lp *lookupPeer) Write(data []byte) (int, error) {
	lp.conn.SetWriteDeadline(time.Now().Add(time.Second))
	return lp.conn.Write(data)
}
1172526
func (w *builtinWriter) Write(b []byte) (int, error) {
	return w.writeAndRetry(w.priority, string(b))
}
253989
func (w *syncWriter) Write(p []byte) (n int, err error) {
	w.Lock()
	n, err = w.Writer.Write(p)
	w.Unlock()
	return n, err
}
295158
func Write(w io.Writer, data ...interface{}) error {
	for _, v := range data {
		if err := binary.Write(w, binary.BigEndian, v); err != nil {
			return err
		}
	}

	return nil
}
401773
func (c *IdleTimingConn) Write(b []byte) (int, error) {
	c.closeMutex.RLock()
	n, err := c.doWrite(b)
	c.closeMutex.RUnlock()
	return n, err
}
649749
func (s *Logging) Write(b []byte) (int, error) {
	s.mutex.RLock()
	w := s.writer
	s.mutex.RUnlock()

	return w.Write(b)
}
1121039
func (w *Writer) Write(buf []byte) (int, error) {
	return w.Writer.Write(buf)
}
174661
func (w *fdSyncWriter) Write(p []byte) (n int, err error) {
	w.Lock()
	n, err = w.fdWriter.Write(p)
	w.Unlock()
	return n, err
}
142895
func (se *SimpleElement) Write(w io.Writer) error {
	return write(w, "", "", se)
}
385024
func (w *wrapper) Write(b []byte) (int, error) {
	n, err := w.ResponseWriter.Write(b)
	w.written += n
	return n, err
}
39265
func (w *prodWriter) Write(d []byte) (a int, err error) {
	if w.Writer == nil {
		w.Writer = w.client.baseClient.Bucket(w.bucket).Object(w.relpath).NewWriter(w)
	}

	err = retry.Retry(w, transient.Only(retry.Default), func() (ierr error) {
		a, ierr = w.Writer.Write(d)

		// Assume all Write errors are transient.
		ierr = transient.Tag.Apply(ierr)
		return
	}, func(err error, d time.Duration) {
		log.Fields{
			log.ErrorKey: err,
			"delay":      d,
			"bucket":     w.bucket,
			"path":       w.relpath,
		}.Warningf(w, "Transient error on GS write. Retrying...")
	})

	w.count += int64(a)
	return
}
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
}
1159217
func (mw multiWriter) Write(p []byte) (int, error) {
	done := make(chan result, len(mw))
	for _, w := range mw {
		go send(w, p, done)
	}
	endResult := result{n: len(p)}
	for _ = range mw {
		res := <-done
		if res.err != nil && (endResult.err == nil || res.n < endResult.n) {
			endResult = res
		}
	}
	return endResult.n, endResult.err
}
1101525
func (a *accounter) write(current int64) float64 {
	fromStart := time.Since(a.startTime)
	currentFromStart := current - a.startValue
	if currentFromStart > 0 {
		speed := float64(currentFromStart) / (float64(fromStart) / float64(time.Second))
		return speed
	}
	return 0.0
}
792454
func (lw *LeveledWriter) Write(p []byte) (int, error) {
	return lw.standard.Write(p)
}
1156147
func (p *ProgressWriter) Write(b []byte) (n int, err error) {
	n, err = p.w.Write(b[0:])
	p.updateProgress(int64(n))
	return
}
329237
func (t ThrottleWriter) Write(p []byte) (n int, err error) {

	now := time.Now().UTC()
	if now.Sub(t.Start) < t.Within {
		if t.Count > t.Limit {
			if t.Callback != nil {
				t.Callback()
			}
			return 0, nil
		}
		t.Count++
	} else {
		t.Start = now
		t.Count = 0
	}

	return t.Writer.Write(p)
}