-
Notifications
You must be signed in to change notification settings - Fork 0
/
services.go
36 lines (31 loc) · 1.03 KB
/
services.go
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
// Package app $PF_IGNORE$
package app
import (
"context"
"admini.dev/admini/app/lib/database"
"admini.dev/admini/app/lib/schema"
"admini.dev/admini/app/loader"
"admini.dev/admini/app/loader/lmock"
"admini.dev/admini/app/loader/lmysql"
"admini.dev/admini/app/loader/lpostgres"
"admini.dev/admini/app/loader/lsqlite"
"admini.dev/admini/app/project"
"admini.dev/admini/app/source"
)
type Services struct {
Sources *source.Service
Projects *project.Service
Loaders *loader.Service
}
func NewServices(ctx context.Context, st *State) (*Services, error) {
ls := loader.NewService()
ls.Set(schema.OriginMySQL, lmysql.NewLoader(ctx, st.Logger))
ls.Set(schema.OriginPostgres, lpostgres.NewLoader(ctx, st.Logger))
if database.SQLiteEnabled {
ls.Set(schema.OriginSQLite, lsqlite.NewLoader(ctx, st.Logger))
}
ls.Set(schema.OriginMock, lmock.NewLoader(ctx, st.Logger))
ss := source.NewService(st.Files, ls, st.Logger)
ps := project.NewService(st.Files, ss, ls, st.Logger)
return &Services{Sources: ss, Projects: ps, Loaders: ls}, nil
}