|
@@ -4,8 +4,6 @@ import (
|
|
|
"git.sxidc.com/go-framework/baize/framework/core/api"
|
|
|
"git.sxidc.com/go-framework/baize/framework/core/application"
|
|
|
"git.sxidc.com/go-framework/baize/framework/core/infrastructure"
|
|
|
- "git.sxidc.com/go-framework/baize/framework/core/infrastructure/database/data_service"
|
|
|
- "git.sxidc.com/go-framework/baize/framework/core/infrastructure/database/operations"
|
|
|
)
|
|
|
|
|
|
func NewApplication(conf application.Config) *application.App {
|
|
@@ -14,43 +12,12 @@ func NewApplication(conf application.Config) *application.App {
|
|
|
apiInstance := api.New(api.WithUrlPrefix(apiConfig.UrlPrefix), api.WithPort(apiConfig.Port))
|
|
|
|
|
|
|
|
|
- var infrastructureInstance *infrastructure.Infrastructure
|
|
|
+ infrastructureConfig := new(infrastructure.Config)
|
|
|
+ infrastructureConfig.DatabaseConfig.Operations = conf.InfrastructureConfig.Database.Operations
|
|
|
+ infrastructureConfig.DatabaseConfig.DataService = conf.InfrastructureConfig.Database.DataService
|
|
|
+ infrastructureConfig.CacheConfig = conf.InfrastructureConfig.Cache
|
|
|
|
|
|
- infrastructureConfig := infrastructure.Config{
|
|
|
- DatabaseConfig: infrastructure.DatabaseConfig{},
|
|
|
- }
|
|
|
-
|
|
|
- if conf.InfrastructureConfig.Database.Operations != nil {
|
|
|
- operationsConfig := conf.InfrastructureConfig.Database.Operations
|
|
|
- if operationsConfig != nil {
|
|
|
- infrastructureConfig.DatabaseConfig.Operations = &operations.Config{
|
|
|
- UserName: operationsConfig.UserName,
|
|
|
- Password: operationsConfig.Password,
|
|
|
- Address: operationsConfig.Address,
|
|
|
- Port: operationsConfig.Port,
|
|
|
- Database: operationsConfig.Database,
|
|
|
- MaxConnections: operationsConfig.MaxConnections,
|
|
|
- MaxIdleConnections: operationsConfig.MaxIdleConnections,
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if conf.InfrastructureConfig.Database.DataService != nil {
|
|
|
- dataServiceConfig := conf.InfrastructureConfig.Database.DataService
|
|
|
- if dataServiceConfig != nil {
|
|
|
- infrastructureConfig.DatabaseConfig.DataService = &data_service.Config{
|
|
|
- Token: dataServiceConfig.Token,
|
|
|
- Address: dataServiceConfig.Address,
|
|
|
- HttpPort: dataServiceConfig.HttpPort,
|
|
|
- GrpcPort: dataServiceConfig.GrpcPort,
|
|
|
- Namespace: dataServiceConfig.Namespace,
|
|
|
- DataSource: dataServiceConfig.DataSource,
|
|
|
- TimeoutSec: dataServiceConfig.TimeoutSec,
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- infrastructureInstance = infrastructure.NewInfrastructure(infrastructureConfig)
|
|
|
+ infrastructureInstance := infrastructure.NewInfrastructure(*infrastructureConfig)
|
|
|
|
|
|
return application.New(apiInstance, infrastructureInstance)
|
|
|
}
|