UnifiedSearch: Introduce a DocumentBuilder interface (#96738)

This commit is contained in:
Ryan McKinley
2024-11-21 07:53:25 +02:00
committed by GitHub
parent 8d4db7ac85
commit 0cb6c3d7bf
24 changed files with 1428 additions and 8 deletions
+29
View File
@@ -123,6 +123,18 @@ type BlobConfig struct {
Backend BlobSupport
}
// Passed as input to the constructor
type SearchOptions struct {
// The raw index backend (eg, bleve, frames, parquet, etc)
Backend SearchBackend
// The supported resource types
Resources DocumentBuilderSupplier
// How many threads should build indexes
WorkerThreads int
}
type ResourceServerOptions struct {
// OTel tracer
Tracer trace.Tracer
@@ -136,6 +148,9 @@ type ResourceServerOptions struct {
// Requests based on a search index
Index ResourceIndexServer
// Search options
Search SearchOptions
// Diagnostics
Diagnostics DiagnosticsServer
@@ -225,6 +240,14 @@ func NewResourceServer(opts ResourceServerOptions) (ResourceServer, error) {
cancel: cancel,
}
if opts.Search.Resources != nil {
var err error
s.search, err = newSearchSupport(opts.Search, s.backend, s.blob, opts.Tracer)
if err != nil {
return nil, err
}
}
return s, nil
}
@@ -235,6 +258,7 @@ type server struct {
log *slog.Logger
backend StorageBackend
blob BlobSupport
search *searchSupport
index ResourceIndexServer
diagnostics DiagnosticsServer
access authz.AccessClient
@@ -269,6 +293,11 @@ func (s *server) Init(ctx context.Context) error {
s.initErr = s.initWatcher()
}
// initialize the search index
if s.initErr == nil && s.search != nil {
s.initErr = s.search.init(ctx)
}
if s.initErr != nil {
s.log.Error("error initializing resource server", "error", s.initErr)
}