[config] expose database pool options to config

This commit is contained in:
Aleksandr Soloshenko 2025-03-16 10:54:07 +07:00 committed by Aleksandr
parent 83c3ef7bac
commit 1493a05cea
3 changed files with 8 additions and 0 deletions

View File

@ -13,6 +13,8 @@ database: # database
password: root # database password [DATABASE__PASSWORD]
database: sms # database name [DATABASE__DATABASE]
timezone: UTC # database timezone (important for message TTL calculation) [DATABASE__TIMEZONE]
max_open_conns: 4 # database max open connections (default: 4 * CPU) [DATABASE__MAX_OPEN_CONNS]
max_idle_conns: 2 # database max idle connections (default: 2 * CPU) [DATABASE__MAX_IDLE_CONNS]
fcm: # firebase cloud messaging config
credentials_json: "{}" # firebase credentials json (for public mode only) [FCM__CREDENTIALS_JSON]
timeout_seconds: 1 # push notification send timeout [FCM__DEBOUNCE_SECONDS]

View File

@ -34,6 +34,9 @@ type Database struct {
Database string `yaml:"database" envconfig:"DATABASE__DATABASE"` // database name
Timezone string `yaml:"timezone" envconfig:"DATABASE__TIMEZONE"` // database timezone
Debug bool `yaml:"debug" envconfig:"DATABASE__DEBUG"` // debug mode
MaxOpenConns int `yaml:"max_open_conns" envconfig:"DATABASE__MAX_OPEN_CONNS"` // max open connections
MaxIdleConns int `yaml:"max_idle_conns" envconfig:"DATABASE__MAX_IDLE_CONNS"` // max idle connections
}
type FCMConfig struct {

View File

@ -42,6 +42,9 @@ var Module = fx.Module(
Database: cfg.Database.Database,
Timezone: cfg.Database.Timezone,
Debug: cfg.Database.Debug,
MaxOpenConns: cfg.Database.MaxOpenConns,
MaxIdleConns: cfg.Database.MaxIdleConns,
}
}),
fx.Provide(func(cfg Config) push.Config {