2
0

Replace IsAlive with IsClosed

IsAlive is ambiguous because the connection may be dead and we do not
know it. It implies the possibility of a ping. IsClosed is clearer -- it
does not promise the connection is alive only that it hasn't been
closed.
This commit is contained in:
Jack Christensen
2019-08-24 23:49:59 -05:00
parent d5a6a5e7e0
commit a262126b5c
6 changed files with 19 additions and 25 deletions
+5 -5
View File
@@ -157,7 +157,7 @@ func (c *Conn) Prepare(query string) (driver.Stmt, error) {
}
func (c *Conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error) {
if !c.conn.IsAlive() {
if c.conn.IsClosed() {
return nil, driver.ErrBadConn
}
@@ -181,7 +181,7 @@ func (c *Conn) Begin() (driver.Tx, error) {
}
func (c *Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
if !c.conn.IsAlive() {
if c.conn.IsClosed() {
return nil, driver.ErrBadConn
}
@@ -218,7 +218,7 @@ func (c *Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, e
}
func (c *Conn) ExecContext(ctx context.Context, query string, argsV []driver.NamedValue) (driver.Result, error) {
if !c.conn.IsAlive() {
if c.conn.IsClosed() {
return nil, driver.ErrBadConn
}
@@ -236,7 +236,7 @@ func (c *Conn) ExecContext(ctx context.Context, query string, argsV []driver.Nam
}
func (c *Conn) QueryContext(ctx context.Context, query string, argsV []driver.NamedValue) (driver.Rows, error) {
if !c.conn.IsAlive() {
if c.conn.IsClosed() {
return nil, driver.ErrBadConn
}
@@ -257,7 +257,7 @@ func (c *Conn) QueryContext(ctx context.Context, query string, argsV []driver.Na
}
func (c *Conn) Ping(ctx context.Context) error {
if !c.conn.IsAlive() {
if c.conn.IsClosed() {
return driver.ErrBadConn
}