• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 16879235694

11 Aug 2025 11:52AM UTC coverage: 66.892% (-0.008%) from 66.9%
16879235694

Pull #10148

github

web-flow
Merge b7bf221ae into f3e1f2f35
Pull Request #10148: graph/db+sqldb: different defaults for SQLite and Postgres query options

14 of 47 new or added lines in 3 files covered. (29.79%)

83 existing lines in 24 files now uncovered.

135693 of 202853 relevant lines covered (66.89%)

21580.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/sqldb/config.go
1
package sqldb
2

3
import (
4
        "fmt"
5
        "net/url"
6
        "time"
7
)
8

9
const (
10
        // defaultMaxConns is the number of permitted active and idle
11
        // connections. We want to limit this so it isn't unlimited. We use the
12
        // same value for the number of idle connections as, this can speed up
13
        // queries given a new connection doesn't need to be established each
14
        // time.
15
        defaultMaxConns = 25
16

17
        // connIdleLifetime is the amount of time a connection can be idle.
18
        connIdleLifetime = 5 * time.Minute
19
)
20

21
// SqliteConfig holds all the config arguments needed to interact with our
22
// sqlite DB.
23
//
24
//nolint:ll
25
type SqliteConfig struct {
26
        Timeout        time.Duration `long:"timeout" description:"The time after which a database query should be timed out."`
27
        BusyTimeout    time.Duration `long:"busytimeout" description:"The maximum amount of time to wait for a database connection to become available for a query."`
28
        MaxConnections int           `long:"maxconnections" description:"The maximum number of open connections to the database. Set to zero for unlimited."`
29
        PragmaOptions  []string      `long:"pragmaoptions" description:"A list of pragma options to set on a database connection. For example, 'auto_vacuum=incremental'. Note that the flag must be specified multiple times if multiple options are to be set."`
30
        SkipMigrations bool          `long:"skipmigrations" description:"Skip applying migrations on startup."`
31
        QueryConfig    `group:"query" description:"Configuration for native SQL queries."`
32
}
33

34
// Validate checks that the SqliteConfig values are valid.
NEW
35
func (p *SqliteConfig) Validate() error {
×
NEW
36
        if err := p.QueryConfig.Validate(true); err != nil {
×
NEW
37
                return fmt.Errorf("invalid query config: %w", err)
×
NEW
38
        }
×
39

NEW
40
        return nil
×
41
}
42

43
// PostgresConfig holds the postgres database configuration.
44
//
45
//nolint:ll
46
type PostgresConfig struct {
47
        Dsn            string        `long:"dsn" description:"Database connection string."`
48
        Timeout        time.Duration `long:"timeout" description:"Database connection timeout. Set to zero to disable."`
49
        MaxConnections int           `long:"maxconnections" description:"The maximum number of open connections to the database. Set to zero for unlimited."`
50
        SkipMigrations bool          `long:"skipmigrations" description:"Skip applying migrations on startup."`
51
        QueryConfig    `group:"query" description:"Configuration for native SQL queries."`
52
}
53

54
// Validate checks that the PostgresConfig values are valid.
55
func (p *PostgresConfig) Validate() error {
×
56
        if p.Dsn == "" {
×
57
                return fmt.Errorf("DSN is required")
×
58
        }
×
59

60
        // Parse the DSN as a URL.
61
        _, err := url.Parse(p.Dsn)
×
62
        if err != nil {
×
63
                return fmt.Errorf("invalid DSN: %w", err)
×
64
        }
×
65

NEW
66
        if err := p.QueryConfig.Validate(false); err != nil {
×
NEW
67
                return fmt.Errorf("invalid query config: %w", err)
×
NEW
68
        }
×
69

UNCOV
70
        return nil
×
71
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc