etcdserver/server.go
func (s *EtcdServer) sync(timeout time.Duration) {
	req := pb.Request{
		Method: "SYNC",
		ID:     s.reqIDGen.Next(),
		Time:   time.Now().UnixNano(),
	}
	data := pbutil.MustMarshal(&req)
	// There is no promise that node has leader when do SYNC request,
	// so it uses goroutine to propose.
	ctx, cancel := context.WithTimeout(s.ctx, timeout)
	s.goAttach(func() {
		s.r.Propose(ctx, data)
		cancel()
	})
}
func (s *EtcdServer) sync(timeout time.Duration) {
	req := pb.Request{
		Method: "SYNC",
		ID:     s.reqIDGen.Next(),
		Time:   time.Now().UnixNano(),
	}
	data := pbutil.MustMarshal(&req)
	// There is no promise that node has leader when do SYNC request,
	// so it uses goroutine to propose.
	ctx, cancel := context.WithTimeout(s.ctx, timeout)
	s.goAttach(func() {
		s.r.Propose(ctx, data)
		cancel()
	})
}
func ( s * EtcdServer ) sync ( timeout time . Duration ) { req := pb . Request { Method : " " , ID : s . reqIDGen . Next ( ) , Time : time . Now ( ) . UnixNano ( ) , } data := pbutil . MustMarshal ( & req ) // There is no promise that node has leader when do SYNC request, // so it uses goroutine to propose. ctx , cancel := context . WithTimeout ( s . ctx , timeout ) s . goAttach ( func ( ) { s . r . Propose ( ctx , data ) cancel ( ) } ) }
// sync proposes a SYNC request and is non-blocking.
// This makes no guarantee that the request will be proposed or performed.
// The request will be canceled after the given timeout.
sync proposes a SYNC request and is non - blocking . This makes no guarantee that the request will be proposed or performed . The request will be canceled after the given timeout .