feat: 并发池功能
This commit is contained in:
@@ -47,6 +47,7 @@ type Config struct {
|
||||
CORS types.CORSConfig `json:"cors"`
|
||||
Performance types.PerformanceConfig `json:"performance"`
|
||||
Log types.LogConfig `json:"log"`
|
||||
Database types.DatabaseConfig `json:"database"`
|
||||
RedisDSN string `json:"redis_dsn"`
|
||||
}
|
||||
|
||||
@@ -102,6 +103,7 @@ func (m *Manager) ReloadConfig() error {
|
||||
Performance: types.PerformanceConfig{
|
||||
MaxConcurrentRequests: parseInteger(os.Getenv("MAX_CONCURRENT_REQUESTS"), 100),
|
||||
EnableGzip: parseBoolean(os.Getenv("ENABLE_GZIP"), true),
|
||||
KeyValidationPoolSize: parseInteger(os.Getenv("KEY_VALIDATION_POOL_SIZE"), 10),
|
||||
},
|
||||
Log: types.LogConfig{
|
||||
Level: getEnvOrDefault("LOG_LEVEL", "info"),
|
||||
@@ -110,6 +112,10 @@ func (m *Manager) ReloadConfig() error {
|
||||
FilePath: getEnvOrDefault("LOG_FILE_PATH", "logs/app.log"),
|
||||
EnableRequest: parseBoolean(os.Getenv("LOG_ENABLE_REQUEST"), true),
|
||||
},
|
||||
Database: types.DatabaseConfig{
|
||||
DSN: os.Getenv("DATABASE_DSN"),
|
||||
AutoMigrate: parseBoolean(os.Getenv("DB_AUTO_MIGRATE"), true),
|
||||
},
|
||||
RedisDSN: os.Getenv("REDIS_DSN"),
|
||||
}
|
||||
m.config = config
|
||||
@@ -154,6 +160,11 @@ func (m *Manager) GetRedisDSN() string {
|
||||
return m.config.RedisDSN
|
||||
}
|
||||
|
||||
// GetDatabaseConfig returns the database configuration.
|
||||
func (m *Manager) GetDatabaseConfig() types.DatabaseConfig {
|
||||
return m.config.Database
|
||||
}
|
||||
|
||||
// GetEffectiveServerConfig returns server configuration merged with system settings
|
||||
func (m *Manager) GetEffectiveServerConfig() types.ServerConfig {
|
||||
config := m.config.Server
|
||||
@@ -217,6 +228,7 @@ func (m *Manager) DisplayConfig() {
|
||||
}
|
||||
logrus.Infof(" CORS: %s", corsStatus)
|
||||
logrus.Infof(" Max concurrent requests: %d", perfConfig.MaxConcurrentRequests)
|
||||
logrus.Infof(" Concurrency pool size: %d", perfConfig.KeyValidationPoolSize)
|
||||
|
||||
gzipStatus := "disabled"
|
||||
if perfConfig.EnableGzip {
|
||||
|
Reference in New Issue
Block a user