mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 16:51:55 +00:00
This PR fixes a few more imports from /internal/ packages using /cmd/... contents. Test plan: Mainly moved code around and CI still passes.
36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package codeintel
|
|
|
|
import (
|
|
"database/sql"
|
|
|
|
codeintelshared "github.com/sourcegraph/sourcegraph/internal/codeintel/shared"
|
|
"github.com/sourcegraph/sourcegraph/internal/conf"
|
|
"github.com/sourcegraph/sourcegraph/internal/conf/conftypes"
|
|
connections "github.com/sourcegraph/sourcegraph/internal/database/connections/live"
|
|
"github.com/sourcegraph/sourcegraph/internal/memo"
|
|
"github.com/sourcegraph/sourcegraph/internal/observation"
|
|
"github.com/sourcegraph/sourcegraph/lib/errors"
|
|
)
|
|
|
|
func InitDB(observationCtx *observation.Context) (codeintelshared.CodeIntelDB, error) {
|
|
rawDB, err := initDBMemo.Init(observationCtx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return codeintelshared.NewCodeIntelDB(observationCtx.Logger, rawDB), nil
|
|
}
|
|
|
|
var initDBMemo = memo.NewMemoizedConstructorWithArg(func(observationCtx *observation.Context) (*sql.DB, error) {
|
|
dsn := conf.GetServiceConnectionValueAndRestartOnChange(func(serviceConnections conftypes.ServiceConnections) string {
|
|
return serviceConnections.CodeIntelPostgresDSN
|
|
})
|
|
|
|
db, err := connections.EnsureNewCodeIntelDB(observationCtx, dsn, "worker")
|
|
if err != nil {
|
|
return nil, errors.Errorf("failed to connect to codeintel database: %s", err)
|
|
}
|
|
|
|
return db, nil
|
|
})
|