mysql configuration for logging and conntimeout

Reviewed By: alexsn

Differential Revision: D15973145

fbshipit-source-id: c8baa475318dff7c80aacee4c9f90651084e20e8
This commit is contained in:
Ariel Mashraki
2019-06-25 02:14:06 -07:00
committed by Facebook Github Bot
parent 0e605681b2
commit 84be4c5653

View File

@@ -11,6 +11,10 @@ import (
"fbc/ent/dialect"
)
// DefaultConnLifeTime to set the maximum amount of time a connection may be reused.
// MySQL server default values are: connect_timeout=10s and wait_timeout=28800s.
var DefaultConnLifeTime = 10 * time.Second
// Driver is a dialect.Driver implementation for SQL based databases.
type Driver struct {
conn
@@ -23,6 +27,7 @@ func Open(driver, source string) (*Driver, error) {
if err != nil {
return nil, err
}
db.SetConnMaxLifetime(DefaultConnLifeTime)
return &Driver{conn{db}, driver}, nil
}
@@ -71,7 +76,7 @@ type ExecQuerier interface {
QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
}
// shared connection ExecQuerier between Gremlin and Tx.
// shared connection ExecQuerier between Driver and Tx.
type conn struct {
ExecQuerier
}