Exemple #1
0
func (s *dbStore) GetSnapshot(ver kv.Version) (kv.MvccSnapshot, error) {
	s.mu.RLock()
	closed := s.closed
	s.mu.RUnlock()

	if closed {
		return nil, errors.Trace(ErrDBClosed)
	}

	providerMu.RLock()
	currentVer, err := globalVersionProvider.CurrentVersion()
	providerMu.RUnlock()
	if err != nil {
		return nil, errors.Trace(err)
	}

	if ver.Cmp(currentVer) > 0 {
		ver = currentVer
	}

	return &dbSnapshot{
		store:   s,
		db:      s.db,
		version: ver,
	}, nil
}
Exemple #2
0
func (s *dbStore) GetSnapshot(ver kv.Version) (kv.Snapshot, error) {
	s.mu.RLock()
	if s.closed {
		s.mu.RUnlock()
		return nil, ErrDBClosed
	}
	s.mu.RUnlock()

	currentVer, err := globalVersionProvider.CurrentVersion()
	if err != nil {
		return nil, errors.Trace(err)
	}

	if ver.Cmp(currentVer) > 0 {
		ver = currentVer
	}

	return &dbSnapshot{
		store:   s,
		version: ver,
	}, nil
}