Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added max db connections config #1068

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading