From c0e18cca9ddd8f219ae451f596f9d79234c98451 Mon Sep 17 00:00:00 2001 From: Kang Ming Date: Sun, 6 Mar 2022 19:06:03 +0800 Subject: [PATCH 1/2] fix: make max db pool size configurable --- conf/configuration.go | 7 +++++-- storage/dial.go | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/conf/configuration.go b/conf/configuration.go index 77f210ce9..dbea9bebe 100644 --- a/conf/configuration.go +++ b/conf/configuration.go @@ -38,8 +38,11 @@ type SamlProviderConfiguration struct { // DBConfiguration holds all the database related configuration. type DBConfiguration struct { - Driver string `json:"driver" required:"true"` - URL string `json:"url" envconfig:"DATABASE_URL" required:"true"` + Driver string `json:"driver" required:"true"` + URL string `json:"url" envconfig:"DATABASE_URL" required:"true"` + + // MaxPoolSize defaults to 0 (unlimited). + MaxPoolSize int `json:"max_pool_size" split_words:"true"` MigrationsPath string `json:"migrations_path" split_words:"true" default:"./migrations"` } diff --git a/storage/dial.go b/storage/dial.go index e176851ea..576198194 100644 --- a/storage/dial.go +++ b/storage/dial.go @@ -31,6 +31,7 @@ func Dial(config *conf.GlobalConfiguration) (*Connection, error) { db, err := pop.NewConnection(&pop.ConnectionDetails{ Dialect: config.DB.Driver, URL: config.DB.URL, + Pool: config.DB.MaxPoolSize, }) if err != nil { return nil, errors.Wrap(err, "opening database connection") From dddb7d3d4b09ba62c677edf0f386254f6d084041 Mon Sep 17 00:00:00 2001 From: Kang Ming Date: Sun, 6 Mar 2022 19:09:48 +0800 Subject: [PATCH 2/2] docs: update readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 9343f0313..31fc6bb57 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,10 @@ Chooses what dialect of database you want. Must be `mysql`. Connection string for the database. +`GOTRUE_DB_MAX_POOL_SIZE` - `int` + +Sets the maximum number of open connections to the database. Defaults to 0 which is equivalent to an "unlimited" number of connections. + `DB_NAMESPACE` - `string` Adds a prefix to all table names.