mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-12-04 18:01:57 +01:00
sqldb+config: validate maximum batch size config value
Now that the SQL query config values are configurable, we add some validation to make sure that the user doesnt set a max batch size that is larger than the limits for sqlite/postgres that have been determined by the TestSQLSliceQueries test.
This commit is contained in:
@@ -31,6 +31,15 @@ type SqliteConfig struct {
|
||||
QueryConfig `group:"query" namespace:"query"`
|
||||
}
|
||||
|
||||
// Validate checks that the SqliteConfig values are valid.
|
||||
func (p *SqliteConfig) Validate() error {
|
||||
if err := p.QueryConfig.Validate(true); err != nil {
|
||||
return fmt.Errorf("invalid query config: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// PostgresConfig holds the postgres database configuration.
|
||||
//
|
||||
//nolint:ll
|
||||
@@ -42,6 +51,7 @@ type PostgresConfig struct {
|
||||
QueryConfig `group:"query" namespace:"query"`
|
||||
}
|
||||
|
||||
// Validate checks that the PostgresConfig values are valid.
|
||||
func (p *PostgresConfig) Validate() error {
|
||||
if p.Dsn == "" {
|
||||
return fmt.Errorf("DSN is required")
|
||||
@@ -53,5 +63,9 @@ func (p *PostgresConfig) Validate() error {
|
||||
return fmt.Errorf("invalid DSN: %w", err)
|
||||
}
|
||||
|
||||
if err := p.QueryConfig.Validate(false); err != nil {
|
||||
return fmt.Errorf("invalid query config: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user