-
Notifications
You must be signed in to change notification settings - Fork 0
/
services.go
42 lines (36 loc) · 1.2 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
37
38
39
40
41
42
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/loader/lsqlserver"
"admini.dev/admini/app/project"
"admini.dev/admini/app/source"
"admini.dev/admini/app/util"
)
type Services struct {
Sources *source.Service
Projects *project.Service
Loaders *loader.Service
}
func NewServices(ctx context.Context, st *State, logger util.Logger) (*Services, error) {
ls := loader.NewService()
ls.Set(schema.OriginMySQL, lmysql.NewLoader(ctx, logger))
ls.Set(schema.OriginPostgres, lpostgres.NewLoader(ctx, logger))
if database.SQLiteEnabled {
ls.Set(schema.OriginSQLite, lsqlite.NewLoader(ctx, logger))
}
ls.Set(schema.OriginSQLServer, lsqlserver.NewLoader(ctx, logger))
ls.Set(schema.OriginMock, lmock.NewLoader(ctx))
ss := source.NewService(st.Files, ls)
ps := project.NewService(st.Files, ss, ls)
return &Services{Sources: ss, Projects: ps, Loaders: ls}, nil
}
func (s *Services) Close(_ context.Context, _ util.Logger) error {
return nil
}