From cf03e0e33859b213f1d7e55b300a074eea107100 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Wed, 1 Aug 2018 20:28:45 -0700 Subject: Create database package (refactoring) --- config/config.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'config/config.go') diff --git a/config/config.go b/config/config.go index 4cba789..580f01d 100644 --- a/config/config.go +++ b/config/config.go @@ -20,6 +20,7 @@ const ( defaultPollingFrequency = 60 defaultBatchSize = 10 defaultDatabaseMaxConns = 20 + defaultDatabaseMinConns = 1 defaultListenAddr = "127.0.0.1:8080" defaultCertFile = "" defaultKeyFile = "" @@ -119,11 +120,16 @@ func (c *Config) DatabaseURL() string { return value } -// DatabaseMaxConnections returns the number of maximum database connections. -func (c *Config) DatabaseMaxConnections() int { +// DatabaseMaxConns returns the maximum number of database connections. +func (c *Config) DatabaseMaxConns() int { return c.getInt("DATABASE_MAX_CONNS", defaultDatabaseMaxConns) } +// DatabaseMinConns returns the minimum number of database connections. +func (c *Config) DatabaseMinConns() int { + return c.getInt("DATABASE_MIN_CONNS", defaultDatabaseMinConns) +} + // ListenAddr returns the listen address for the HTTP server. func (c *Config) ListenAddr() string { if port := os.Getenv("PORT"); port != "" { -- cgit v1.2.3