ListBlocks implements backend.Reader
(_ context.Context, tenant string)
| 157 | |
| 158 | // ListBlocks implements backend.Reader |
| 159 | func (rw *Backend) ListBlocks(_ context.Context, tenant string) (metas []uuid.UUID, compactedMetas []uuid.UUID, err error) { |
| 160 | rootPath := rw.rootPath(backend.KeyPath{tenant}) |
| 161 | fff := os.DirFS(rootPath) |
| 162 | err = fs.WalkDir(fff, ".", func(path string, _ fs.DirEntry, err error) error { |
| 163 | if err != nil { |
| 164 | return err |
| 165 | } |
| 166 | |
| 167 | tenantFilePath := filepath.Join(tenant, path) |
| 168 | |
| 169 | parts := strings.Split(tenantFilePath, pathSeparatorStr) |
| 170 | // i.e: <tenantID/<blockID>/meta |
| 171 | if len(parts) != 3 { |
| 172 | return nil |
| 173 | } |
| 174 | |
| 175 | if parts[2] != backend.MetaName && parts[2] != backend.CompactedMetaName { |
| 176 | return nil |
| 177 | } |
| 178 | |
| 179 | id, err := uuid.Parse(parts[1]) |
| 180 | if err != nil { |
| 181 | return err |
| 182 | } |
| 183 | |
| 184 | switch parts[2] { |
| 185 | case backend.MetaName: |
| 186 | metas = append(metas, id) |
| 187 | case backend.CompactedMetaName: |
| 188 | compactedMetas = append(compactedMetas, id) |
| 189 | } |
| 190 | |
| 191 | return nil |
| 192 | }) |
| 193 | |
| 194 | return |
| 195 | } |
| 196 | |
| 197 | // Find implements backend.Reader |
| 198 | func (rw *Backend) Find(_ context.Context, keypath backend.KeyPath, f backend.FindFunc) (err error) { |