code: func (s *storageImpl) getIndex(c context.Context) (*logpb.LogIndex, error) {
  	idx := s.index.Load()
  	if idx != nil {
  		return idx.(*logpb.LogIndex), nil
  	}
  
  	index, err := loadIndex(c, s.Client, s.Index, s.Cache)
  	switch errors.Unwrap(err) {
  	case nil:
  		break
  
  	case cloudStorage.ErrBucketNotExist, cloudStorage.ErrObjectNotExist:
  		// Treat a missing index the same as an empty index.
  		log.WithError(err).Warningf(c, "Index is invalid, using empty index.")
  		index = &logpb.LogIndex{}
  
  	default:
  		return nil, err
  	}
  
  	s.index.Store(index)
  	return index, nil
  }
docs: // getIndex returns the cached log stream index, fetching it if necessary.