forked from sourcegraph/sourcegraph-public-snapshot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.go
More file actions
52 lines (45 loc) · 1.47 KB
/
init.go
File metadata and controls
52 lines (45 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package codenav
import (
"github.com/sourcegraph/sourcegraph/internal/codeintel/codenav/internal/lsifstore"
"github.com/sourcegraph/sourcegraph/internal/codeintel/codenav/internal/store"
codeintelshared "github.com/sourcegraph/sourcegraph/internal/codeintel/shared"
"github.com/sourcegraph/sourcegraph/internal/database"
"github.com/sourcegraph/sourcegraph/internal/memo"
"github.com/sourcegraph/sourcegraph/internal/observation"
)
// GetService creates or returns an already-initialized symbols service.
// If the service is not yet initialized, it will use the provided dependencies.
func GetService(
db database.DB,
codeIntelDB codeintelshared.CodeIntelDB,
uploadSvc UploadService,
gitserver GitserverClient,
) *Service {
svc, _ := initServiceMemo.Init(serviceDependencies{
db,
codeIntelDB,
uploadSvc,
gitserver,
})
return svc
}
type serviceDependencies struct {
db database.DB
codeIntelDB codeintelshared.CodeIntelDB
uploadSvc UploadService
gitserver GitserverClient
}
var initServiceMemo = memo.NewMemoizedConstructorWithArg(func(deps serviceDependencies) (*Service, error) {
store := store.New(deps.db, scopedContext("store"))
lsifStore := lsifstore.New(deps.codeIntelDB, scopedContext("lsifstore"))
return newService(
store,
lsifStore,
deps.uploadSvc,
deps.gitserver,
scopedContext("service"),
), nil
})
func scopedContext(component string) *observation.Context {
return observation.ScopedContext("codeintel", "codenav", component)
}