mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
mysql configuration for logging and conntimeout
Reviewed By: alexsn Differential Revision: D15973145 fbshipit-source-id: c8baa475318dff7c80aacee4c9f90651084e20e8
This commit is contained in:
committed by
Facebook Github Bot
parent
0e605681b2
commit
84be4c5653
@@ -11,6 +11,10 @@ import (
|
|||||||
"fbc/ent/dialect"
|
"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.
|
// Driver is a dialect.Driver implementation for SQL based databases.
|
||||||
type Driver struct {
|
type Driver struct {
|
||||||
conn
|
conn
|
||||||
@@ -23,6 +27,7 @@ func Open(driver, source string) (*Driver, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
db.SetConnMaxLifetime(DefaultConnLifeTime)
|
||||||
return &Driver{conn{db}, driver}, nil
|
return &Driver{conn{db}, driver}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +76,7 @@ type ExecQuerier interface {
|
|||||||
QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
|
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 {
|
type conn struct {
|
||||||
ExecQuerier
|
ExecQuerier
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user