-
Notifications
You must be signed in to change notification settings - Fork 0
/
platform.go
84 lines (69 loc) · 1.96 KB
/
platform.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
72
73
74
75
76
77
78
79
80
81
82
83
84
package yarus_platform
import (
"context"
"github.com/minipkg/log"
"github.com/yaruz/app/pkg/yarus_platform/config"
"github.com/yaruz/app/pkg/yarus_platform/data"
"github.com/yaruz/app/pkg/yarus_platform/data/domain/entity"
"github.com/yaruz/app/pkg/yarus_platform/infrastructure"
"github.com/yaruz/app/pkg/yarus_platform/reference"
)
type IPlatform interface {
Stop() error
DataSubsystem() *data.DataSubsystem
ReferenceSubsystem() *reference.ReferenceSubsystem
//SearchSubsystem() *search.SearchSubsystem
AutoMigrate(metadata *config.Metadata) error
}
type Platform struct {
cfg config.Configuration
dataSubsystem *data.DataSubsystem
referenceSubsystem *reference.ReferenceSubsystem
//searchSubsystem *search.SearchSubsystem
infra *infrastructure.Infrastructure
}
func NewPlatform(ctx context.Context, cfg *config.Configuration) (*Platform, error) {
logger, err := log.New(cfg.Infrastructure.Log)
if err != nil {
return nil, err
}
infra, err := infrastructure.NewInfrastructure(ctx, logger, cfg.Infrastructure, entity.New())
if err != nil {
return nil, err
}
reference, err := reference.NewReferenceSubsystem(infra, cfg)
if err != nil {
return nil, err
}
//search, err := search.NewSearchSubsystem(infra)
//if err != nil {
// return nil, err
//}
data, err := data.NewDataSubsystem(infra, reference)
if err != nil {
return nil, err
}
return &Platform{
cfg: *cfg,
dataSubsystem: data,
referenceSubsystem: reference,
//searchSubsystem: search,
infra: infra,
}, nil
}
func (r *Platform) DataSubsystem() *data.DataSubsystem {
return r.dataSubsystem
}
func (r *Platform) ReferenceSubsystem() *reference.ReferenceSubsystem {
return r.referenceSubsystem
}
//
//func (r *Platform) SearchSubsystem() *search.SearchSubsystem {
// return r.searchSubsystem
//}
func (r *Platform) Stop() error {
return r.infra.Stop()
}
func (r *Platform) AutoMigrate(metadata *config.Metadata) error {
return nil
}