func (p *pipeline) post(data []byte) (err error) {
	u := p.picker.pick()
	req := createPostRequest(u, RaftPrefix, bytes.NewBuffer(data), "application/protobuf", p.tr.URLs, p.from, p.cid)
	done := make(chan struct{}, 1)
	cancel := httputil.RequestCanceler(p.tr.pipelineRt, req)
	go func() {
		select {
		case <-done:
		case <-p.stopc:
			waitSchedule()
			cancel()
		}
	}()
	resp, err := p.tr.pipelineRt.RoundTrip(req)
	done <- struct{}{}
	if err != nil {
		p.picker.unreachable(u)
		return err
	}
	b, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		p.picker.unreachable(u)
		return err
	}
	resp.Body.Close()
	err = checkPostResponse(resp, b, req, p.to)
	if err != nil {
		p.picker.unreachable(u)
		if err == errMemberRemoved {
			reportCriticalError(err, p.errorc)
		}
		return err
	}
	return nil
}
post POSTs a data payload to a url. Returns nil if the POST succeeds,
error on any failure.
package rafthttp
import (
	"bytes"
	"errors"
	"io/ioutil"
	"sync"
	"time"
	"github.com/coreos/etcd/etcdserver/stats"
	"github.com/coreos/etcd/pkg/httputil"
	"github.com/coreos/etcd/pkg/pbutil"
	"github.com/coreos/etcd/pkg/types"
	"github.com/coreos/etcd/raft"
	"github.com/coreos/etcd/raft/raftpb"
)
const (
	connPerPipeline = 4
	pipelineBufSize = 64
)
var errStopped = errors.New("stopped")
type pipeline struct {
	from, to types.ID
	cid      types.ID
	tr     *Transport
	picker *urlPicker
	status *peerStatus
	fs     *stats.FollowerStats
	r      Raft
	errorc chan error
	msgc chan raftpb.Message
	wg    sync.WaitGroup
	stopc chan struct{}
}
func newPipeline(tr *Transport, picker *urlPicker, from, to, cid types.ID, status *peerStatus, fs *stats.FollowerStats, r Raft, errorc chan error) *pipeline {
	p := &pipeline{
		from:   from,
		to:     to,
		cid:    cid,
		tr:     tr,
		picker: picker,
		status: status,
		fs:     fs,
		r:      r,
		errorc: errorc,
		stopc:  make(chan struct{}),
		msgc:   make(chan raftpb.Message, pipelineBufSize),
	}
	p.wg.Add(connPerPipeline)
	for i := 0; i < connPerPipeline; i++ {
		go p.handle()
	}
	return p
}
func (p *pipeline) stop() {
	close(p.stopc)
	p.wg.Wait()
}
func (p *pipeline) handle() {
	defer p.wg.Done()
	for {
		select {
		case m := <-p.msgc:
			start := time.Now()
			err := p.post(pbutil.MustMarshal(&m))
			end := time.Now()
			if err != nil {
				p.status.deactivate(failureType{source: pipelineMsg, action: "write"}, err.Error())
				reportSentFailure(pipelineMsg, m)
				if m.Type == raftpb.MsgApp && p.fs != nil {
					p.fs.Fail()
				}
				p.r.ReportUnreachable(m.To)
				if isMsgSnap(m) {
					p.r.ReportSnapshot(m.To, raft.SnapshotFailure)
				}
				continue
			}
			p.status.activate()
			if m.Type == raftpb.MsgApp && p.fs != nil {
				p.fs.Succ(end.Sub(start))
			}
			if isMsgSnap(m) {
				p.r.ReportSnapshot(m.To, raft.SnapshotFinish)
			}
			reportSentDuration(pipelineMsg, m, time.Since(start))
		case <-p.stopc:
			return
		}
	}
}