pastebin/internal/repositories/sqlite.go

33 lines
573 B
Go
Raw Normal View History

2023-09-30 13:47:59 +00:00
package repositories
import (
2024-03-18 17:03:14 +00:00
"time"
2023-09-30 13:47:59 +00:00
"gitter.top/drivers/sdbc"
2024-03-18 17:03:14 +00:00
2023-09-30 13:47:59 +00:00
"pastebin/config"
2024-03-18 17:03:14 +00:00
genv1 "pastebin/gen/v1"
2023-09-30 13:47:59 +00:00
)
var (
driver *sdbc.Driver
pastebinOperator sdbc.Operator
)
func GetPastebin() sdbc.Operator {
if driver == nil {
cfg := config.Get()
driver = sdbc.NewSDBC(&sdbc.Config{
Dbname: cfg.DBConfig.Dbname,
MaxIdleConn: 20,
MaxOpenConn: 200,
MaxLifetime: time.Hour,
Debug: cfg.DBConfig.Debug,
})
}
if pastebinOperator == nil {
2024-03-18 17:03:14 +00:00
pastebinOperator = driver.BindModel(&genv1.ModelPastebin{})
2023-09-30 13:47:59 +00:00
}
return pastebinOperator
}