Skip to content

Commit

Permalink
added max db connections config (#1068)
Browse files Browse the repository at this point in the history
* added max db connections config

* fix lint
  • Loading branch information
brennanjl authored Oct 21, 2024
1 parent e8510e5 commit aa94e4c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ var DefaultConfig = func() *commonConfig.KwildConfig {
ChallengeExpiry: commonConfig.Duration(10 * time.Second),
ChallengeRateLimit: 10.0, // req/s
ReadTxTimeout: commonConfig.Duration(5 * time.Second),
MaxDBConnections: 24,
Extensions: make(map[string]map[string]string),
Snapshots: commonConfig.SnapshotConfig{
Enable: false,
Expand Down
1 change: 1 addition & 0 deletions cmd/kwild/config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func AddConfigFlags(flagSet *pflag.FlagSet, cfg *config.KwildConfig) {
flagSet.MarkDeprecated("app.rpc-req-limit", "use --app.rpc-max-req-size instead")

flagSet.Var(&cfg.AppConfig.ReadTxTimeout, "app.db-read-timeout", "timeout for database reads initiated by RPC requests")
flagSet.Uint32Var(&cfg.AppConfig.MaxDBConnections, "app.db-max-connections", cfg.AppConfig.MaxDBConnections, "maximum number of database connections")

// genesis state / migration flags
flagSet.StringVar(&cfg.AppConfig.GenesisState, "app.genesis-state", cfg.AppConfig.GenesisState, "Path to the genesis state file")
Expand Down
2 changes: 1 addition & 1 deletion cmd/kwild/server/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ func buildDB(d *coreDependencies, closer *closeFuncs) *pg.DB {
// If yes, restore the database from the snapshot
fromSnapshot := restoreDB(d)

db, err := d.dbOpener(d.ctx, d.cfg.AppConfig.DBName, 24)
db, err := d.dbOpener(d.ctx, d.cfg.AppConfig.DBName, d.cfg.AppConfig.MaxDBConnections)
if err != nil {
failBuild(err, "kwild database open failed")
}
Expand Down
1 change: 1 addition & 0 deletions common/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ type AppConfig struct {
ChallengeExpiry Duration `mapstructure:"challenge_expiry"`
ChallengeRateLimit float64 `mapstructure:"challenge_rate_limit"`
ReadTxTimeout Duration `mapstructure:"db_read_timeout"`
MaxDBConnections uint32 `mapstructure:"db_max_connections"`
ExtensionEndpoints []string `mapstructure:"extension_endpoints"`
AdminRPCPass string `mapstructure:"admin_pass"`
NoTLS bool `mapstructure:"admin_notls"`
Expand Down

0 comments on commit aa94e4c

Please sign in to comment.