DATABSE_MODE => STATEDIFF_MODE

This commit is contained in:
Roy Crihfield 2023-09-29 10:20:34 +08:00
parent 0153371995
commit 58ac1bfb20
2 changed files with 6 additions and 7 deletions

View File

@ -67,7 +67,7 @@ const (
DATABASE_USER = "DATABASE_USER"
DATABASE_PASSWORD = "DATABASE_PASSWORD"
DATABASE_TYPE = "DATABASE_TYPE"
STATEDIFF_MODE = "STATEDIFF_MODE"
DATABASE_DRIVER_TYPE = "DATABASE_DRIVER_TYPE"
DATABASE_DUMP_DST = "DATABASE_DUMP_DST"
DATABASE_FILE_PATH = "DATABASE_FILE_PATH"
@ -109,7 +109,6 @@ func init() {
viper.BindEnv("database.connTimeout", DATABASE_CONN_TIMEOUT)
viper.BindEnv("database.maxIdleTime", DATABASE_MAX_CONN_IDLE_TIME)
viper.BindEnv("database.type", DATABASE_TYPE)
viper.BindEnv("database.driver", DATABASE_DRIVER_TYPE)
viper.BindEnv("database.dumpDestination", DATABASE_DUMP_DST)
viper.BindEnv("database.fileMode", DATABASE_FILE_MODE)
@ -130,6 +129,7 @@ func init() {
viper.BindEnv("prom.httpPort", PROM_HTTP_PORT)
viper.BindEnv("prom.dbStats", PROM_DB_STATS)
viper.BindEnv("statediff.mode", STATEDIFF_MODE)
viper.BindEnv("statediff.serviceWorkers", STATEDIFF_SERVICE_WORKERS)
viper.BindEnv("statediff.trieWorkers", STATEDIFF_TRIE_WORKERS)
viper.BindEnv("statediff.workerQueueSize", STATEDIFF_WORKER_QUEUE_SIZE)

View File

@ -294,14 +294,13 @@ func randSeq(n int) string {
// getConfig constructs and returns the appropriate config from viper params
func getConfig(nodeInfo node.Info) (interfaces.Config, error) {
dbTypeStr := viper.GetString("database.type")
dbType, err := shared.ResolveDBType(dbTypeStr)
outputMode, err := shared.ResolveDBType(viper.GetString("statediff.mode"))
if err != nil {
return nil, err
}
logWithCommand.Debugf("Configuring service for database type: %s", dbType)
logWithCommand.Debugf("Configuring service for database type: %s", outputMode)
var indexerConfig interfaces.Config
switch dbType {
switch outputMode {
case shared.FILE:
logWithCommand.Info("Starting in sql file writing mode")
@ -378,7 +377,7 @@ func getConfig(nodeInfo node.Info) (interfaces.Config, error) {
}
indexerConfig = pgConfig
default:
return nil, fmt.Errorf("unrecognized db type: %s", dbType)
return nil, fmt.Errorf("unrecognized db type: %s", outputMode)
}
return indexerConfig, nil
}