3
0
Files
corteza/pkg/options/db.go
2020-09-08 07:54:23 +02:00

31 lines
441 B
Go

package options
import (
"strings"
"time"
)
type (
DBOpt struct {
DSN string `env:"DB_DSN"`
}
)
func DB(pfix string) (o *DBOpt) {
const delay = 15 * time.Second
const maxTries = 100
o = &DBOpt{
DSN: "mysql://corteza:corteza@tcp(db:3306)/corteza?collation=utf8mb4_general_ci",
}
fill(o)
if !strings.Contains(o.DSN, "://") {
// Make sure DSN is compatible with new requirements
o.DSN = "mysql://" + o.DSN
}
return
}