Skip to content

Commit

Permalink
FeatL Export config
Browse files Browse the repository at this point in the history
  • Loading branch information
kienmatu committed Oct 10, 2023
1 parent 14c7f5e commit 47dd85f
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion mserver/mserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/manabie-com/rio/internal/config"
"github.com/manabie-com/rio/internal/database"
"github.com/manabie-com/rio/internal/log"
fs "github.com/manabie-com/rio/internal/storage"
)

func StartServerWithConfig(cfg *config.Config) {
Expand All @@ -21,7 +22,7 @@ func StartServerWithConfig(cfg *config.Config) {
panic(err)
}

dbConfig := config.NewDBConfig()
dbConfig := cfg.DB
if err := database.Migrate(ctx, dbConfig, "schema/migration"); err != nil {
panic(err)
}
Expand All @@ -31,3 +32,31 @@ func StartServerWithConfig(cfg *config.Config) {
panic(err)
}
}

// NewConfig
// serverAddress: 0.0.0.0:8896
func NewConfig(serverAddr, dbHost, dbName, dbSchema, dbUser, dbPassword, dbPort string) *config.Config {
return &config.Config{
ServerAddress: serverAddr,
DB: NewDBConfig(dbHost, dbName, dbSchema, dbUser, dbPassword, dbPort, 20, 2, 4),
FileStorageType: "local",
FileStorage: fs.LocalStorageConfig{
UseTempDir: true,
StoragePath: "uploaded_files",
},
}
}

func NewDBConfig(host, dbName, dbSchema, user, password, port string, connectionLifetimeSeconds, maxIdleConnections, maxOpenConnections int) *config.PostgresConfig {
return &config.PostgresConfig{
Host: host,
DBName: dbName,
DBSchema: dbSchema,
User: user,
Password: password,
Port: port,
ConnectionLifetimeSeconds: connectionLifetimeSeconds,
MaxIdleConnections: maxIdleConnections,
MaxOpenConnections: maxOpenConnections,
}
}

0 comments on commit 47dd85f

Please sign in to comment.