code: func (w *WALWatcher) segments(dir string) ([]int, error) {
  	files, err := fileutil.ReadDir(dir)
  	if err != nil {
  		return nil, err
  	}
  
  	var refs []int
  	var last int
  	for _, fn := range files {
  		k, err := strconv.Atoi(fn)
  		if err != nil {
  			continue
  		}
  		if len(refs) > 0 && k > last+1 {
  			return nil, errors.New("segments are not sequential")
  		}
  		refs = append(refs, k)
  		last = k
  	}
  	sort.Ints(refs)
  
  	return refs, nil
  }
docs: // Copied from tsdb/wal/wal.go so we do not have to open a WAL.
  // Plan is to move WAL watcher to TSDB and dedupe these implementations.