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

lightningnetwork / lnd / 16969463412

14 Aug 2025 03:23PM UTC coverage: 66.776% (-0.2%) from 66.929%
16969463412

push

github

web-flow
Merge pull request #10155 from ziggie1984/add-missing-invoice-settle-index

Add missing invoice index for native sql

135916 of 203540 relevant lines covered (66.78%)

21469.17 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" namespace:"query"`
32
}
33

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

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" namespace:"query"`
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

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

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