BucketScanBlocksFinder is a BlocksFinder implementation periodically scanning the bucket to discover blocks.
| 52 | |
| 53 | // BucketScanBlocksFinder is a BlocksFinder implementation periodically scanning the bucket to discover blocks. |
| 54 | type BucketScanBlocksFinder struct { |
| 55 | services.Service |
| 56 | |
| 57 | cfg BucketScanBlocksFinderConfig |
| 58 | cfgProvider bucket.TenantConfigProvider |
| 59 | logger log.Logger |
| 60 | bucketClient objstore.Bucket |
| 61 | fetchersMetrics *storegateway.MetadataFetcherMetrics |
| 62 | usersScanner users.Scanner |
| 63 | |
| 64 | // We reuse the metadata fetcher instance for a given tenant both because of performance |
| 65 | // reasons (the fetcher keeps a in-memory cache) and being able to collect and group metrics. |
| 66 | fetchersMx sync.Mutex |
| 67 | fetchers map[string]userFetcher |
| 68 | |
| 69 | // Keep the per-tenant/user metas found during the last run. |
| 70 | userMx sync.RWMutex |
| 71 | userMetas map[string]bucketindex.Blocks |
| 72 | userMetasLookup map[string]map[ulid.ULID]*bucketindex.Block |
| 73 | userDeletionMarks map[string]map[ulid.ULID]*bucketindex.BlockDeletionMark |
| 74 | |
| 75 | scanDuration prometheus.Histogram |
| 76 | scanLastSuccess prometheus.Gauge |
| 77 | } |
| 78 | |
| 79 | func NewBucketScanBlocksFinder(cfg BucketScanBlocksFinderConfig, usersScanner users.Scanner, bucketClient objstore.InstrumentedBucket, cfgProvider bucket.TenantConfigProvider, logger log.Logger, reg prometheus.Registerer) *BucketScanBlocksFinder { |
| 80 | d := &BucketScanBlocksFinder{ |
nothing calls this directly
no outgoing calls
no test coverage detected