code: func (s *Store) raftApply(typ byte, cmd []byte) (uint64, error) {
  	s.mu.RLock()
  	if s.raft == nil {
  		s.mu.RUnlock()
  		return 0, ErrShutdown
  	}
  	s.mu.RUnlock()
  
  	// Join the command type and data into one message.
  	buf := append([]byte{typ}, cmd...)
  
  	// Apply to raft and receive an ApplyFuture back.
  	f := s.raft.Apply(buf, 30*time.Second)
  	if err := f.Error(); err == raft.ErrNotLeader {
  		return 0, ErrNotLeader // hide underlying implementation error
  	} else if err != nil {
  		return f.Index(), err
  	} else if err, ok := f.Response().(error); ok {
  		return f.Index(), err
  	}
  
  	return f.Index(), nil
  }
docs: // raftApply joins typ and cmd and applies it to raft.
  // This call blocks until the apply completes and returns the error.