| 
					
				 | 
			
			
				@@ -1,6 +1,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package db 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	"context" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"database/sql" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"fmt" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"sync" 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -94,9 +95,11 @@ func (d *DB) Connect() (err error) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // Close close database connect 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-func (d *DB) Close() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	// use pool 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	//d.c.Close() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func (d *DB) Close() error { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if d.c != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return d.c.Close() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	return nil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // Ping verifies a connection to the database is still alive, establishing a connection if necessary. 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -104,6 +107,11 @@ func (d *DB) Ping() error { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	return d.c.Ping() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// PingContext verifies a connection to the database is still alive, establishing a connection if necessary. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func (d *DB) PingContext(ctx context.Context) error { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	return d.c.PingContext(ctx) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // Stats returns database statistics. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 func (d *DB) Stats() sql.DBStats { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	return d.c.Stats() 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -292,6 +300,16 @@ func Ping() error { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	return defaultDb.Ping() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// PingContext verifies a connection to the database is still alive, establishing a connection if necessary. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func PingContext(ctx context.Context) error { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	return defaultDb.PingContext(ctx) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// Close close database connect 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func Close() error { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	return defaultDb.Close() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // Stats returns database statistics. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 func Stats() sql.DBStats { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	return defaultDb.Stats() 
			 |