code: func (s *Store) Connect(opt *ConnectionOptions) (*Connection, error) {
  	// Randomly-selected connection ID must be part of command so
  	// that all nodes use the same value as connection ID.
  	connID := func() uint64 {
  		s.connsMu.Lock()
  		defer s.connsMu.Unlock()
  		for {
  			// Make sure we get an unused ID.
  			id := s.randSrc.Uint64()
  			if _, ok := s.conns[id]; !ok {
  				s.conns[id] = nil
  				return id
  			}
  		}
  	}()
  
  	var it time.Duration
  	var tt time.Duration
  	if opt != nil {
  		it = opt.IdleTimeout
  		tt = opt.TxTimeout
  	}
  
  	d := &connectionSub{connID, it, tt}
  	cmd, err := newCommand(connect, d)
  	if err != nil {
  		return nil, err
  	}
  	b, err := json.Marshal(cmd)
  	if err != nil {
  		return nil, err
  	}
  
  	f := s.raft.Apply(b, s.ApplyTimeout)
  	if e := f.(raft.Future); e.Error() != nil {
  		if e.Error() == raft.ErrNotLeader {
  			return nil, ErrNotLeader
  		}
  		return nil, e.Error()
  	}
  
  	s.connsMu.RLock()
  	defer s.connsMu.RUnlock()
  	stats.Add(numConnects, 1)
  	return s.conns[connID], nil
  }
docs: // Connect returns a new connection to the database. Changes made to the database
  // through this connection are applied via the Raft consensus system. The Store
  // must have been opened first. Must be called on the leader or an error will
  // we returned.
  //
  // Any connection returned by this call are READ_COMMITTED isolated from all
  // other connections, including the connection built-in to the Store itself.