示例#1
0
func (mc *MergedConfig) Int(key string) (int, error) {
	value, err := mc.c.Int(mc.env, key)
	if err != nil {
		logger.Errorf("failed to get int value. key=%s", key)
		return -9999, err
	}

	return value, nil
}
示例#2
0
func (mc *MergedConfig) String(key string) (string, error) {
	value, err := mc.c.String(mc.env, key)
	if err != nil {
		logger.Errorf("failed to get string value. key=%s", key)
		return "", err
	}

	return value, nil
}
示例#3
0
func init() {
	dialectName, _ := config.String("db.dialect")
	connectionString, _ := config.String("db.connection_string")

	db, err := gorm.Open(dialectName, connectionString)
	if err != nil {
		logger.Errorf("failed to open connection. dialect=%s, connectionString=%s", dialectName, connectionString)
		panic(err)
	}

	db.DB()
	db.DB().Ping()
	db.DB().SetMaxIdleConns(2)  // TODO
	db.DB().SetMaxOpenConns(10) // TODO

	db.LogMode(true) // TODO
	// db.SetLogger(Logger) // TODO format, implement gorm.Logger

	DB = &db
}