mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 17:31:43 +00:00
59 lines
1.4 KiB
Go
59 lines
1.4 KiB
Go
package codeintel
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/sourcegraph/sourcegraph/cmd/worker/job"
|
|
"github.com/sourcegraph/sourcegraph/cmd/worker/shared/init/codeintel"
|
|
workerdb "github.com/sourcegraph/sourcegraph/cmd/worker/shared/init/db"
|
|
"github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing"
|
|
"github.com/sourcegraph/sourcegraph/internal/codeintel/policies"
|
|
"github.com/sourcegraph/sourcegraph/internal/env"
|
|
"github.com/sourcegraph/sourcegraph/internal/goroutine"
|
|
"github.com/sourcegraph/sourcegraph/internal/observation"
|
|
)
|
|
|
|
type autoindexingScheduler struct{}
|
|
|
|
func NewAutoindexingSchedulerJob() job.Job {
|
|
return &autoindexingScheduler{}
|
|
}
|
|
|
|
func (j *autoindexingScheduler) Description() string {
|
|
return ""
|
|
}
|
|
|
|
func (j *autoindexingScheduler) Config() []env.Config {
|
|
return []env.Config{
|
|
autoindexing.SchedulerConfigInst,
|
|
}
|
|
}
|
|
|
|
func (j *autoindexingScheduler) Routines(_ context.Context, observationCtx *observation.Context) ([]goroutine.BackgroundRoutine, error) {
|
|
services, err := codeintel.InitServices(observationCtx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
db, err := workerdb.InitDB(observationCtx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
matcher := policies.NewMatcher(
|
|
services.GitserverClient,
|
|
policies.IndexingExtractor,
|
|
false,
|
|
true,
|
|
)
|
|
|
|
return autoindexing.NewIndexSchedulers(
|
|
observationCtx,
|
|
services.UploadsService,
|
|
services.PoliciesService,
|
|
matcher,
|
|
services.AutoIndexingService,
|
|
db.Repos(),
|
|
), nil
|
|
}
|