This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathfactory.go
48 lines (40 loc) · 1.47 KB
/
factory.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
43
44
45
46
47
48
package repositories
import (
"fmt"
"github.com/lyft/flytestdlib/promutils"
"github.com/lyft/flyteadmin/pkg/repositories/config"
"github.com/lyft/flyteadmin/pkg/repositories/errors"
"github.com/lyft/flyteadmin/pkg/repositories/interfaces"
)
type RepoConfig int32
const (
POSTGRES RepoConfig = 0
)
var RepositoryConfigurationName = map[int32]string{
0: "POSTGRES",
}
// The RepositoryInterface indicates the methods that each Repository must support.
// A Repository indicates a Database which is collection of Tables/models.
// The goal is allow databases to be Plugged in easily.
type RepositoryInterface interface {
TaskRepo() interfaces.TaskRepoInterface
WorkflowRepo() interfaces.WorkflowRepoInterface
LaunchPlanRepo() interfaces.LaunchPlanRepoInterface
ExecutionRepo() interfaces.ExecutionRepoInterface
ProjectRepo() interfaces.ProjectRepoInterface
NodeExecutionRepo() interfaces.NodeExecutionRepoInterface
TaskExecutionRepo() interfaces.TaskExecutionRepoInterface
}
func GetRepository(repoType RepoConfig, dbConfig config.DbConfig, scope promutils.Scope) RepositoryInterface {
switch repoType {
case POSTGRES:
postgresScope := scope.NewSubScope("postgres")
db := config.OpenDbConnection(config.NewPostgresConfigProvider(dbConfig, postgresScope))
return NewPostgresRepo(
db,
errors.NewPostgresErrorTransformer(postgresScope.NewSubScope("errors")),
postgresScope.NewSubScope("repositories"))
default:
panic(fmt.Sprintf("Invalid repoType %v", repoType))
}
}