fix(db): allow unlimited connections (#6758)

This commit is contained in:
Silvan 2023-10-19 15:37:22 +02:00 committed by GitHub
parent 3a01558c61
commit 4d4f649eda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,7 +16,7 @@ func NewConnectionInfo(openConns, idleConns uint32, pusherRatio float64) (*Conne
if pusherRatio < 0 || pusherRatio > 1 {
return nil, errors.New("EventPushConnRatio must be between 0 and 1")
}
if openConns < 2 {
if openConns != 0 && openConns < 2 {
return nil, errors.New("MaxOpenConns of the database must be higher that 1")
}
@ -25,15 +25,19 @@ func NewConnectionInfo(openConns, idleConns uint32, pusherRatio float64) (*Conne
info.EventstorePusher.MaxOpenConns = uint32(pusherRatio * float64(openConns))
info.EventstorePusher.MaxIdleConns = uint32(pusherRatio * float64(idleConns))
if info.EventstorePusher.MaxOpenConns < 1 && pusherRatio > 0 {
if openConns != 0 && info.EventstorePusher.MaxOpenConns < 1 && pusherRatio > 0 {
info.EventstorePusher.MaxOpenConns = 1
}
if info.EventstorePusher.MaxIdleConns < 1 && pusherRatio > 0 {
if idleConns != 0 && info.EventstorePusher.MaxIdleConns < 1 && pusherRatio > 0 {
info.EventstorePusher.MaxIdleConns = 1
}
info.ZITADEL.MaxOpenConns = openConns - info.EventstorePusher.MaxOpenConns
info.ZITADEL.MaxIdleConns = idleConns - info.EventstorePusher.MaxIdleConns
if openConns != 0 {
info.ZITADEL.MaxOpenConns = openConns - info.EventstorePusher.MaxOpenConns
}
if idleConns != 0 {
info.ZITADEL.MaxIdleConns = idleConns - info.EventstorePusher.MaxIdleConns
}
return info, nil
}