Skip to content

Commit

Permalink
extra option to set MaxOpenConns/MaxIdleConns for sqlite3 storage
Browse files Browse the repository at this point in the history
  • Loading branch information
mattn committed Sep 30, 2023
1 parent 01fde86 commit 87f4a8e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions storage/sqlite3/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ func (b *SQLite3Backend) Init() error {
return err
}

// sqlx default is 0 (unlimited), while sqlite3 by default accepts up to 100 connections
db.SetMaxOpenConns(80)
db.SetMaxOpenConns(b.MaxOpenConns)
db.SetMaxIdleConns(b.MaxIdleConns)

db.Mapper = reflectx.NewMapperFunc("json", sqlx.NameMapper)
b.DB = db
Expand Down
4 changes: 3 additions & 1 deletion storage/sqlite3/sqlite3.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ import (

type SQLite3Backend struct {
*sqlx.DB
DatabaseURL string
DatabaseURL string
MaxOpenConns int
MaxIdleConns int
}

0 comments on commit 87f4a8e

Please sign in to comment.