@@ -83,7 +83,7 @@ func getAlloyDBDialOpts(ipType string) ([]alloydbconn.DialOption, error) {
8383 }
8484}
8585
86- func initAlloyDBPgConnectionPool (project , region , cluster , instance , ipType , user , pass , dbname string ) (* pgxpool.Pool , error ) {
86+ func initAlloyDBPgConnectionPool (ctx context. Context , project , region , cluster , instance , ipType , user , pass , dbname string ) (* pgxpool.Pool , error ) {
8787 dsn := fmt .Sprintf ("user=%s password=%s dbname=%s sslmode=disable" , user , pass , dbname )
8888 config , err := pgxpool .ParseConfig (dsn )
8989 if err != nil {
@@ -94,7 +94,7 @@ func initAlloyDBPgConnectionPool(project, region, cluster, instance, ipType, use
9494 if err != nil {
9595 return nil , err
9696 }
97- d , err := alloydbconn .NewDialer (context . Background () , alloydbconn .WithDefaultDialOptions (dialOpts ... ))
97+ d , err := alloydbconn .NewDialer (ctx , alloydbconn .WithDefaultDialOptions (dialOpts ... ))
9898 if err != nil {
9999 return nil , fmt .Errorf ("unable to parse connection uri: %w" , err )
100100 }
@@ -104,7 +104,7 @@ func initAlloyDBPgConnectionPool(project, region, cluster, instance, ipType, use
104104 return d .Dial (ctx , i )
105105 }
106106
107- pool , err := pgxpool .NewWithConfig (context . Background () , config )
107+ pool , err := pgxpool .NewWithConfig (ctx , config )
108108 if err != nil {
109109 return nil , err
110110 }
@@ -148,7 +148,7 @@ func TestAlloyDBPgCallTool(t *testing.T) {
148148 ctx , cancel := context .WithTimeout (context .Background (), 2 * time .Minute )
149149 defer cancel ()
150150
151- pool , err := initAlloyDBPgConnectionPool (AlloyDBPostgresProject , AlloyDBPostgresRegion , AlloyDBPostgresCluster , AlloyDBPostgresInstance , "public" , AlloyDBPostgresUser , AlloyDBPostgresPass , AlloyDBPostgresDatabase )
151+ pool , err := initAlloyDBPgConnectionPool (ctx , AlloyDBPostgresProject , AlloyDBPostgresRegion , AlloyDBPostgresCluster , AlloyDBPostgresInstance , "public" , AlloyDBPostgresUser , AlloyDBPostgresPass , AlloyDBPostgresDatabase )
152152 if err != nil {
153153 t .Fatalf ("unable to create AlloyDB connection pool: %s" , err )
154154 }
0 commit comments