Browse Source

SetConnMaxLifetime, SetMaxIdleConns, SetMaxOpenConns

Volodymyr Tkach 2 years ago
parent
commit
6409d07bbc
1 changed files with 5 additions and 0 deletions
  1. 5 0
      main.go

+ 5 - 0
main.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"io/ioutil"
 	"path/filepath"
+	"time"
 
 	"github.com/vladimirok5959/golang-sql/gosql"
 )
@@ -30,6 +31,10 @@ func main() {
 		panic(fmt.Sprintf("%s", err))
 	}
 
+	db.SetConnMaxLifetime(time.Minute * 60)
+	db.SetMaxIdleConns(8)
+	db.SetMaxOpenConns(8)
+
 	// DB struct here ./db/migrations/20220527233113_test_migration.sql
 	fmt.Println("Insert some data to users table")
 	if _, err := db.Exec(