mirror of
https://github.com/jackc/pgx.git
synced 2025-05-29 10:42:31 +00:00
Wrap stdlib Conn.Close() and Stmt.Close() with default 5 seconds timeout.
This commit is contained in:
parent
e5920c3ad9
commit
e27a6e71b5
@ -225,7 +225,9 @@ func (c *Conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, e
|
||||
}
|
||||
|
||||
func (c *Conn) Close() error {
|
||||
return c.conn.Close(context.Background())
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
||||
defer cancel()
|
||||
return c.conn.Close(ctx)
|
||||
}
|
||||
|
||||
func (c *Conn) Begin() (driver.Tx, error) {
|
||||
@ -325,7 +327,9 @@ type Stmt struct {
|
||||
}
|
||||
|
||||
func (s *Stmt) Close() error {
|
||||
return s.conn.conn.Deallocate(context.Background(), s.sd.Name)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
||||
defer cancel()
|
||||
return s.conn.conn.Deallocate(ctx, s.sd.Name)
|
||||
}
|
||||
|
||||
func (s *Stmt) NumInput() int {
|
||||
|
Loading…
x
Reference in New Issue
Block a user