Unified Storage Indexer: Build tenant indexes concurrently (#95795)
* WIP - build tenant indexes concurrently * adds local dev seeders and readme for indexer * update logging and adds locking in getShard() * update logs * Adds Namespaces func. Initializes index after ResourceServer is created. * fixes Count() and updates test lint issues * Initialize index separately. Don't do it when creating the resource server. Makes testing really awkward. * fix lint error * handles error when getting namespaces * updates test and index helper funcs
This commit is contained in:
@@ -137,6 +137,31 @@ func (b *backend) WriteEvent(ctx context.Context, event resource.WriteEvent) (in
|
||||
}
|
||||
}
|
||||
|
||||
// Namespaces returns the list of unique namespaces in storage.
|
||||
func (b *backend) Namespaces(ctx context.Context) ([]string, error) {
|
||||
var namespaces []string
|
||||
|
||||
err := b.db.WithTx(ctx, RepeatableRead, func(ctx context.Context, tx db.Tx) error {
|
||||
rows, err := tx.QueryContext(ctx, "SELECT DISTINCT(namespace) FROM resource ORDER BY namespace;")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for rows.Next() {
|
||||
var ns string
|
||||
err = rows.Scan(&ns)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
namespaces = append(namespaces, ns)
|
||||
}
|
||||
|
||||
err = rows.Close()
|
||||
return err
|
||||
})
|
||||
|
||||
return namespaces, err
|
||||
}
|
||||
|
||||
func (b *backend) create(ctx context.Context, event resource.WriteEvent) (int64, error) {
|
||||
ctx, span := b.tracer.Start(ctx, tracePrefix+"Create")
|
||||
defer span.End()
|
||||
|
||||
Reference in New Issue
Block a user