Skip to content

Commit

Permalink
added max db conns
Browse files Browse the repository at this point in the history
  • Loading branch information
brennanjl committed Oct 9, 2024
1 parent cb0f6f6 commit c382055
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cmd/kwild/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ type AppConfig struct {
RPCTimeout Duration `mapstructure:"rpc_timeout"`
RPCMaxReqSize int `mapstructure:"rpc_req_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 Expand Up @@ -566,6 +567,7 @@ func DefaultConfig() *KwildConfig {
RPCTimeout: Duration(45 * time.Second),
RPCMaxReqSize: 4_200_000,
ReadTxTimeout: Duration(5 * time.Second),
MaxDBConnections: 24,
Extensions: make(map[string]map[string]string),
Snapshots: SnapshotConfig{
Enabled: 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 @@ -38,6 +38,7 @@ func AddConfigFlags(flagSet *pflag.FlagSet, cfg *KwildConfig) {
flagSet.Var(&cfg.AppCfg.RPCTimeout, "app.rpc-timeout", "timeout for RPC requests (through reading the request, handling the request, and sending the response)")
flagSet.IntVar(&cfg.AppCfg.RPCMaxReqSize, "app.rpc-req-limit", cfg.AppCfg.RPCMaxReqSize, "RPC request size limit")
flagSet.Var(&cfg.AppCfg.ReadTxTimeout, "app.db-read-timeout", "timeout for database reads initiated by RPC requests")
flagSet.Uint32Var(&cfg.AppCfg.MaxDBConnections, "app.db-max-connections", cfg.AppCfg.MaxDBConnections, "maximum number of database connections")

// Extension endpoints flags
flagSet.StringSliceVar(&cfg.AppCfg.ExtensionEndpoints, "app.extension-endpoints", cfg.AppCfg.ExtensionEndpoints, "kwild extension endpoints")
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 @@ -426,7 +426,7 @@ func buildDB(d *coreDependencies, closer *closeFuncs) *pg.DB {
// If yes, restore the database from the snapshot
restoreDB(d)

db, err := d.dbOpener(d.ctx, d.cfg.AppCfg.DBName, 24)
db, err := d.dbOpener(d.ctx, d.cfg.AppCfg.DBName, uint32(d.cfg.AppCfg.MaxDBConnections))
if err != nil {
failBuild(err, "kwild database open failed")
}
Expand Down

0 comments on commit c382055

Please sign in to comment.