sqldb+lncfg: consolidate SQLite default constants
Move the SQLite default constants (max connections, busy timeout) to sqldb/config.go as the single source of truth and export them. Remove the duplicate definitions from lncfg/db.go and reference the sqldb constants instead.
This commit is contained in:
2 files changed
+9
-12
No files matched your search
+2
-5
@@ -40,9 +40,6 @@ const (
|
|||||||
DefaultBatchCommitInterval = 500 * time.Millisecond
|
DefaultBatchCommitInterval = 500 * time.Millisecond
|
||||||
|
|
||||||
defaultPostgresMaxConnections = 50
|
defaultPostgresMaxConnections = 50
|
||||||
defaultSqliteMaxConnections = 2
|
|
||||||
|
|
||||||
defaultSqliteBusyTimeout = 5 * time.Second
|
|
||||||
|
|
||||||
// NSChannelDB is the namespace name that we use for the combined graph
|
// NSChannelDB is the namespace name that we use for the combined graph
|
||||||
// and channel state DB.
|
// and channel state DB.
|
||||||
@@ -126,8 +123,8 @@ func DefaultDB() *DB {
|
|||||||
QueryConfig: *sqldb.DefaultPostgresConfig(),
|
QueryConfig: *sqldb.DefaultPostgresConfig(),
|
||||||
},
|
},
|
||||||
Sqlite: &sqldb.SqliteConfig{
|
Sqlite: &sqldb.SqliteConfig{
|
||||||
MaxConnections: defaultSqliteMaxConnections,
|
MaxConnections: sqldb.DefaultSqliteMaxConns,
|
||||||
BusyTimeout: defaultSqliteBusyTimeout,
|
BusyTimeout: sqldb.DefaultSqliteBusyTimeout,
|
||||||
QueryConfig: *sqldb.DefaultSQLiteConfig(),
|
QueryConfig: *sqldb.DefaultSQLiteConfig(),
|
||||||
},
|
},
|
||||||
UseNativeSQL: false,
|
UseNativeSQL: false,
|
||||||
|
|||||||
+7
-7
@@ -32,15 +32,15 @@ type SqliteConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// defaultSqliteMaxConns is the default number of maximum open
|
// DefaultSqliteMaxConns is the default number of maximum open
|
||||||
// connections for SQLite. SQLite only supports a single writer, so a
|
// connections for SQLite. SQLite only supports a single writer, so a
|
||||||
// low default reduces contention on the busy_timeout and limits
|
// low default reduces contention on the busy_timeout and limits
|
||||||
// resource usage, especially on mobile.
|
// resource usage, especially on mobile.
|
||||||
defaultSqliteMaxConns = 2
|
DefaultSqliteMaxConns = 2
|
||||||
|
|
||||||
// defaultBusyTimeoutMs is the default busy_timeout value in
|
// DefaultSqliteBusyTimeout is the default busy_timeout value used
|
||||||
// milliseconds, used when no BusyTimeout is configured.
|
// when no BusyTimeout is configured.
|
||||||
defaultBusyTimeoutMs = 5000
|
DefaultSqliteBusyTimeout = 5 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
// busyTimeoutMs returns the busy_timeout value in milliseconds. If
|
// busyTimeoutMs returns the busy_timeout value in milliseconds. If
|
||||||
@@ -50,7 +50,7 @@ func (s *SqliteConfig) busyTimeoutMs() int64 {
|
|||||||
return s.BusyTimeout.Milliseconds()
|
return s.BusyTimeout.Milliseconds()
|
||||||
}
|
}
|
||||||
|
|
||||||
return defaultBusyTimeoutMs
|
return DefaultSqliteBusyTimeout.Milliseconds()
|
||||||
}
|
}
|
||||||
|
|
||||||
// MaxConns returns the effective maximum number of open connections. If
|
// MaxConns returns the effective maximum number of open connections. If
|
||||||
@@ -62,7 +62,7 @@ func (s *SqliteConfig) MaxConns() int {
|
|||||||
return s.MaxConnections
|
return s.MaxConnections
|
||||||
}
|
}
|
||||||
|
|
||||||
return defaultSqliteMaxConns
|
return DefaultSqliteMaxConns
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate checks that the SqliteConfig values are valid.
|
// Validate checks that the SqliteConfig values are valid.
|
||||||
|
|||||||
Reference in new issue
Block a user