Skip to content

Commit

Permalink
defined Default* constants for the pool limits
Browse files Browse the repository at this point in the history
  • Loading branch information
ganigeorgiev committed Dec 15, 2022
1 parent b9e257d commit 8e582ac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
21 changes: 14 additions & 7 deletions core/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ import (
"github.com/pocketbase/pocketbase/tools/subscriptions"
)

const (
DefaultDataMaxOpenConns int = 100
DefaultDataMaxIdleConns int = 20
DefaultLogsMaxOpenConns int = 10
DefaultLogsMaxIdleConns int = 2
)

var _ App = (*BaseApp)(nil)

// BaseApp implements core.App and defines the base PocketBase app structure.
Expand Down Expand Up @@ -139,10 +146,10 @@ type BaseAppConfig struct {
DataDir string
EncryptionEnv string
IsDebug bool
DataMaxOpenConns int // default to 600
DataMaxOpenConns int // default to 500
DataMaxIdleConns int // default 20
LogsMaxOpenConns int // default to 500
LogsMaxIdleConns int // default to 10
LogsMaxOpenConns int // default to 100
LogsMaxIdleConns int // default to 5
}

// NewBaseApp creates and returns a new BaseApp instance
Expand Down Expand Up @@ -802,8 +809,8 @@ func (app *BaseApp) OnCollectionsAfterImportRequest() *hook.Hook[*CollectionsImp
// -------------------------------------------------------------------

func (app *BaseApp) initLogsDB() error {
maxOpenConns := 500
maxIdleConns := 10
maxOpenConns := DefaultLogsMaxOpenConns
maxIdleConns := DefaultLogsMaxIdleConns
if app.logsMaxOpenConns > 0 {
maxOpenConns = app.logsMaxOpenConns
}
Expand Down Expand Up @@ -833,8 +840,8 @@ func (app *BaseApp) initLogsDB() error {
}

func (app *BaseApp) initDataDB() error {
maxOpenConns := 600
maxIdleConns := 20
maxOpenConns := DefaultDataMaxOpenConns
maxIdleConns := DefaultDataMaxIdleConns
if app.dataMaxOpenConns > 0 {
maxOpenConns = app.dataMaxOpenConns
}
Expand Down
8 changes: 4 additions & 4 deletions pocketbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ type Config struct {
HideStartBanner bool

// optional DB configurations
DataMaxOpenConns int // default to 600
DataMaxIdleConns int // default 20
LogsMaxOpenConns int // default to 500
LogsMaxIdleConns int // default to 10
DataMaxOpenConns int // default to core.DefaultDataMaxOpenConns
DataMaxIdleConns int // default to core.DefaultDataMaxIdleConns
LogsMaxOpenConns int // default to core.DefaultLogsMaxOpenConns
LogsMaxIdleConns int // default to core.DefaultLogsMaxIdleConns
}

// New creates a new PocketBase instance with the default configuration.
Expand Down

0 comments on commit 8e582ac

Please sign in to comment.