refactor: new bun config
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
2cc015a0c2
commit
88f7608db7
|
@ -23,9 +23,8 @@ const (
|
||||||
type bunConfig struct {
|
type bunConfig struct {
|
||||||
DSN string `envconfig:"DSN" required:"true"`
|
DSN string `envconfig:"DSN" required:"true"`
|
||||||
MaxOpenConnections int `envconfig:"MAX_OPEN_CONNECTIONS" default:"5"`
|
MaxOpenConnections int `envconfig:"MAX_OPEN_CONNECTIONS" default:"5"`
|
||||||
MaxIdleConnections int `envconfig:"MAX_IDLE_CONNECTIONS" default:"5"`
|
MaxIdleConnections int `envconfig:"MAX_IDLE_CONNECTIONS" default:"2"`
|
||||||
ConnectionMaxLifetime time.Duration `envconfig:"CONNECTION_MAX_LIFETIME" default:"3m"`
|
ConnectionMaxLifetime time.Duration `envconfig:"CONNECTION_MAX_LIFETIME" default:"3m"`
|
||||||
ConnectionMaxIdleTime time.Duration `envconfig:"CONNECTION_MAX_IDLE_TIME" default:"5m"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBunDB() (*bun.DB, error) {
|
func NewBunDB() (*bun.DB, error) {
|
||||||
|
@ -51,6 +50,5 @@ func newSQLDB(cfg bunConfig) *sql.DB {
|
||||||
db.SetMaxOpenConns(cfg.MaxOpenConnections)
|
db.SetMaxOpenConns(cfg.MaxOpenConnections)
|
||||||
db.SetMaxIdleConns(cfg.MaxIdleConnections)
|
db.SetMaxIdleConns(cfg.MaxIdleConnections)
|
||||||
db.SetConnMaxLifetime(cfg.ConnectionMaxLifetime)
|
db.SetConnMaxLifetime(cfg.ConnectionMaxLifetime)
|
||||||
db.SetConnMaxIdleTime(cfg.ConnectionMaxIdleTime)
|
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ spec:
|
||||||
- name: DB_MAX_OPEN_CONNECTIONS
|
- name: DB_MAX_OPEN_CONNECTIONS
|
||||||
value: "10"
|
value: "10"
|
||||||
- name: DB_MAX_IDLE_CONNECTIONS
|
- name: DB_MAX_IDLE_CONNECTIONS
|
||||||
value: "2"
|
value: "3"
|
||||||
- name: BOT_TOKEN
|
- name: BOT_TOKEN
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
|
|
|
@ -19,7 +19,7 @@ spec:
|
||||||
- name: DB_MAX_OPEN_CONNECTIONS
|
- name: DB_MAX_OPEN_CONNECTIONS
|
||||||
value: "15"
|
value: "15"
|
||||||
- name: DB_MAX_IDLE_CONNECTIONS
|
- name: DB_MAX_IDLE_CONNECTIONS
|
||||||
value: "8"
|
value: "7"
|
||||||
- name: BOT_TOKEN
|
- name: BOT_TOKEN
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user