mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:07:31 +00:00
fix(db): add additional connection pool for projection spooling (#7094)
* fix(db): add additional connection pool for projection spooling * use correct connection pool for projections --------- Co-authored-by: Livio Spring <livio.a@gmail.com>
This commit is contained in:
@@ -68,28 +68,19 @@ func (c *Config) Decode(configs []interface{}) (dialect.Connector, error) {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (c *Config) Connect(useAdmin, isEventPusher bool, pusherRatio float32, appName string) (*sql.DB, error) {
|
||||
client, err := sql.Open("pgx", c.String(useAdmin, appName))
|
||||
func (c *Config) Connect(useAdmin bool, pusherRatio, spoolerRatio float64, purpose dialect.DBPurpose) (*sql.DB, error) {
|
||||
client, err := sql.Open("pgx", c.String(useAdmin, purpose.AppName()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
connInfo, err := dialect.NewConnectionInfo(c.MaxOpenConns, c.MaxIdleConns, float64(pusherRatio))
|
||||
connConfig, err := dialect.NewConnectionConfig(c.MaxOpenConns, c.MaxIdleConns, spoolerRatio, pusherRatio, purpose)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var maxConns, maxIdleConns uint32
|
||||
if isEventPusher {
|
||||
maxConns = connInfo.EventstorePusher.MaxOpenConns
|
||||
maxIdleConns = connInfo.EventstorePusher.MaxIdleConns
|
||||
} else {
|
||||
maxConns = connInfo.ZITADEL.MaxOpenConns
|
||||
maxIdleConns = connInfo.ZITADEL.MaxIdleConns
|
||||
}
|
||||
|
||||
client.SetMaxOpenConns(int(maxConns))
|
||||
client.SetMaxIdleConns(int(maxIdleConns))
|
||||
client.SetMaxOpenConns(int(connConfig.MaxIdleConns))
|
||||
client.SetMaxIdleConns(int(connConfig.MaxIdleConns))
|
||||
client.SetConnMaxLifetime(c.MaxConnLifetime)
|
||||
client.SetConnMaxIdleTime(c.MaxConnIdleTime)
|
||||
|
||||
|
Reference in New Issue
Block a user