1
mirror of https://gitlab.com/commento/commento.git synced 2025-06-29 22:56:37 -04:00

api: add MAX_IDLE_PG_CONNECTIONS config variable

This allows lib/pq to maintain that many idle connections to the
PostgreSQL server. The larger the number the better, but obviously, your
machine needs to be capable to maintain that many connections.

Closes https://gitlab.com/commento/commento-ce/issues/76
This commit is contained in:
Adhityaa Chandrasekar
2018-08-16 23:12:21 +05:30
parent 3339944cf2
commit 9f14a9389c
3 changed files with 53 additions and 7 deletions

View File

@ -125,3 +125,32 @@ func TestConfigOriginTrailingSlash(t *testing.T) {
return
}
}
func TestConfigMaxConnections(t *testing.T) {
os.Setenv("COMMENTO_ORIGIN", "https://commento.io")
os.Setenv("COMMENTO_STATIC", "")
os.Setenv("COMMENTO_MAX_IDLE_PG_CONNECTIONS", "100")
if err := configParse(); err != nil {
t.Errorf("unexpected error when MAX_IDLE_PG_CONNECTIONS=100: %v", err)
return
}
os.Setenv("COMMENTO_MAX_IDLE_PG_CONNECTIONS", "text")
if err := configParse(); err == nil {
t.Errorf("expected error with MAX_IDLE_PG_CONNECTIONS=text not found")
return
}
os.Setenv("COMMENTO_MAX_IDLE_PG_CONNECTIONS", "0")
if err := configParse(); err == nil {
t.Errorf("expected error with MAX_IDLE_PG_CONNECTIONS=0 not found")
return
}
os.Setenv("COMMENTO_MAX_IDLE_PG_CONNECTIONS", "-1")
if err := configParse(); err == nil {
t.Errorf("expected error with MAX_IDLE_PG_CONNECTIONS=-1 not found")
return
}
}