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
/
postgres_repo.go
71 lines (59 loc) · 2.73 KB
/
postgres_repo.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package repositories
import (
"github.com/flyteorg/flyteadmin/pkg/repositories/errors"
"github.com/flyteorg/flyteadmin/pkg/repositories/gormimpl"
"github.com/flyteorg/flyteadmin/pkg/repositories/interfaces"
"github.com/flyteorg/flytestdlib/promutils"
"github.com/jinzhu/gorm"
)
type PostgresRepo struct {
executionRepo interfaces.ExecutionRepoInterface
namedEntityRepo interfaces.NamedEntityRepoInterface
launchPlanRepo interfaces.LaunchPlanRepoInterface
projectRepo interfaces.ProjectRepoInterface
nodeExecutionRepo interfaces.NodeExecutionRepoInterface
taskRepo interfaces.TaskRepoInterface
taskExecutionRepo interfaces.TaskExecutionRepoInterface
workflowRepo interfaces.WorkflowRepoInterface
resourceRepo interfaces.ResourceRepoInterface
}
func (p *PostgresRepo) ExecutionRepo() interfaces.ExecutionRepoInterface {
return p.executionRepo
}
func (p *PostgresRepo) LaunchPlanRepo() interfaces.LaunchPlanRepoInterface {
return p.launchPlanRepo
}
func (p *PostgresRepo) NamedEntityRepo() interfaces.NamedEntityRepoInterface {
return p.namedEntityRepo
}
func (p *PostgresRepo) ProjectRepo() interfaces.ProjectRepoInterface {
return p.projectRepo
}
func (p *PostgresRepo) NodeExecutionRepo() interfaces.NodeExecutionRepoInterface {
return p.nodeExecutionRepo
}
func (p *PostgresRepo) TaskRepo() interfaces.TaskRepoInterface {
return p.taskRepo
}
func (p *PostgresRepo) TaskExecutionRepo() interfaces.TaskExecutionRepoInterface {
return p.taskExecutionRepo
}
func (p *PostgresRepo) WorkflowRepo() interfaces.WorkflowRepoInterface {
return p.workflowRepo
}
func (p *PostgresRepo) ResourceRepo() interfaces.ResourceRepoInterface {
return p.resourceRepo
}
func NewPostgresRepo(db *gorm.DB, errorTransformer errors.ErrorTransformer, scope promutils.Scope) RepositoryInterface {
return &PostgresRepo{
executionRepo: gormimpl.NewExecutionRepo(db, errorTransformer, scope.NewSubScope("executions")),
launchPlanRepo: gormimpl.NewLaunchPlanRepo(db, errorTransformer, scope.NewSubScope("launch_plans")),
projectRepo: gormimpl.NewProjectRepo(db, errorTransformer, scope.NewSubScope("project")),
namedEntityRepo: gormimpl.NewNamedEntityRepo(db, errorTransformer, scope.NewSubScope("named_entity")),
nodeExecutionRepo: gormimpl.NewNodeExecutionRepo(db, errorTransformer, scope.NewSubScope("node_executions")),
taskRepo: gormimpl.NewTaskRepo(db, errorTransformer, scope.NewSubScope("tasks")),
taskExecutionRepo: gormimpl.NewTaskExecutionRepo(db, errorTransformer, scope.NewSubScope("task_executions")),
workflowRepo: gormimpl.NewWorkflowRepo(db, errorTransformer, scope.NewSubScope("workflows")),
resourceRepo: gormimpl.NewResourceRepo(db, errorTransformer, scope.NewSubScope("resources")),
}
}