Skip to content

Commit fa7e8f3

Browse files
committed
Renaming conn to connection for consistency
1 parent bd6f3fe commit fa7e8f3

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/client.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ class Client extends Api {
3030
}
3131

3232
async withConnection( action ) {
33-
let conn;
33+
let connection;
3434
const { pool } = this[ _state ];
3535
try {
36-
conn = await pool.acquire();
37-
const result = await action( conn );
36+
connection = await pool.acquire();
37+
const result = await action( connection );
3838
return result;
3939
} finally {
40-
if ( conn ) {
41-
await pool.release( conn );
40+
if ( connection ) {
41+
await pool.release( connection );
4242
}
4343
}
4444
}
@@ -56,7 +56,7 @@ class Client extends Api {
5656
}
5757
const { onBeginTransaction, onEndTransaction } = this[ _state ];
5858

59-
return this.withConnection( conn => Transaction.run( { conn, isolationLevel, action, context, onBeginTransaction, onEndTransaction } ) );
59+
return this.withConnection( connection => Transaction.run( { connection, isolationLevel, action, context, onBeginTransaction, onEndTransaction } ) );
6060
}
6161

6262
async dispose() {

src/transaction.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ class Transaction extends Api {
1010
this.context = context;
1111
}
1212

13-
static async run( { conn, isolationLevel, action, context, onBeginTransaction, onEndTransaction } ) {
14-
const tx = new Transaction( conn, context );
13+
static async run( { connection, isolationLevel, action, context, onBeginTransaction, onEndTransaction } ) {
14+
const tx = new Transaction( connection, context );
1515
try {
16-
await conn.beginTransaction( "" /* name */, isolationLevel );
16+
await connection.beginTransaction( "" /* name */, isolationLevel );
1717
await onBeginTransaction( tx );
1818
const result = await action( tx );
1919
await onEndTransaction( tx );
20-
await conn.commitTransaction();
20+
await connection.commitTransaction();
2121
return result;
2222
} catch ( err ) {
2323
// TODO: wrap err instead of mangling message
2424
err.message = `Automatic Rollback. Failed Because: ${ err.message }`;
2525
try {
26-
await conn.rollbackTransaction();
26+
await connection.rollbackTransaction();
2727
} catch ( _ ) {
28-
conn.close();
28+
connection.close();
2929
}
3030
throw err;
3131
}

0 commit comments

Comments
 (0)