UnifiedSearch: Introduce a DocumentBuilder interface (#96738)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user