Skip to content

Commit

Permalink
fix: allow max db pool size to be configurable (supabase#409)
Browse files Browse the repository at this point in the history
  • Loading branch information
kangmingtay authored and LashaJini committed Nov 15, 2024
1 parent ae087f2 commit f149745
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 5 additions & 2 deletions conf/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down
1 change: 1 addition & 0 deletions storage/dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit f149745

Please sign in to comment.