Skip to content

Commit 1493a05

Browse files
committed
[config] expose database pool options to config
1 parent 83c3ef7 commit 1493a05

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

configs/config.example.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ database: # database
1313
password: root # database password [DATABASE__PASSWORD]
1414
database: sms # database name [DATABASE__DATABASE]
1515
timezone: UTC # database timezone (important for message TTL calculation) [DATABASE__TIMEZONE]
16+
max_open_conns: 4 # database max open connections (default: 4 * CPU) [DATABASE__MAX_OPEN_CONNS]
17+
max_idle_conns: 2 # database max idle connections (default: 2 * CPU) [DATABASE__MAX_IDLE_CONNS]
1618
fcm: # firebase cloud messaging config
1719
credentials_json: "{}" # firebase credentials json (for public mode only) [FCM__CREDENTIALS_JSON]
1820
timeout_seconds: 1 # push notification send timeout [FCM__DEBOUNCE_SECONDS]

internal/config/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ type Database struct {
3434
Database string `yaml:"database" envconfig:"DATABASE__DATABASE"` // database name
3535
Timezone string `yaml:"timezone" envconfig:"DATABASE__TIMEZONE"` // database timezone
3636
Debug bool `yaml:"debug" envconfig:"DATABASE__DEBUG"` // debug mode
37+
38+
MaxOpenConns int `yaml:"max_open_conns" envconfig:"DATABASE__MAX_OPEN_CONNS"` // max open connections
39+
MaxIdleConns int `yaml:"max_idle_conns" envconfig:"DATABASE__MAX_IDLE_CONNS"` // max idle connections
3740
}
3841

3942
type FCMConfig struct {

internal/config/module.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ var Module = fx.Module(
4242
Database: cfg.Database.Database,
4343
Timezone: cfg.Database.Timezone,
4444
Debug: cfg.Database.Debug,
45+
46+
MaxOpenConns: cfg.Database.MaxOpenConns,
47+
MaxIdleConns: cfg.Database.MaxIdleConns,
4548
}
4649
}),
4750
fx.Provide(func(cfg Config) push.Config {

0 commit comments

Comments
 (0)