close connections in pool
This commit is contained in:
parent
721e465f32
commit
fc73c6840e
3 changed files with 11 additions and 3 deletions
|
@ -1,7 +1,11 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module type="WEB_MODULE" version="4">
|
<module type="WEB_MODULE" version="4">
|
||||||
<component name="NewModuleRootManager">
|
<component name="NewModuleRootManager">
|
||||||
<content url="file://$MODULE_DIR$/angel_orm" />
|
<content url="file://$MODULE_DIR$/angel_orm">
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/angel_orm/.pub" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/angel_orm/build" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/angel_orm/packages" />
|
||||||
|
</content>
|
||||||
<content url="file://$MODULE_DIR$/angel_orm_generator">
|
<content url="file://$MODULE_DIR$/angel_orm_generator">
|
||||||
<excludeFolder url="file://$MODULE_DIR$/angel_orm_generator/.pub" />
|
<excludeFolder url="file://$MODULE_DIR$/angel_orm_generator/.pub" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/angel_orm_generator/build" />
|
<excludeFolder url="file://$MODULE_DIR$/angel_orm_generator/build" />
|
||||||
|
|
|
@ -37,7 +37,11 @@ class PostgreSQLConnectionPool {
|
||||||
Future<T> run<T>(FutureOr<T> callback(PostgreSQLConnection connection)) {
|
Future<T> run<T>(FutureOr<T> callback(PostgreSQLConnection connection)) {
|
||||||
return _pool.request().then((resx) {
|
return _pool.request().then((resx) {
|
||||||
return _connect().then((connection) {
|
return _connect().then((connection) {
|
||||||
return new Future<T>.sync(() => callback(connection)).whenComplete(resx.release);
|
return new Future<T>.sync(() => callback(connection))
|
||||||
|
.whenComplete(() async {
|
||||||
|
if (!connection.isClosed) await connection.close();
|
||||||
|
resx.release();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
name: angel_orm
|
name: angel_orm
|
||||||
version: 1.0.0-alpha
|
version: 1.0.0-alpha+1
|
||||||
description: Runtime support for Angel's ORM.
|
description: Runtime support for Angel's ORM.
|
||||||
author: Tobe O <thosakwe@gmail.com>
|
author: Tobe O <thosakwe@gmail.com>
|
||||||
homepage: https://github.com/angel-dart/orm
|
homepage: https://github.com/angel-dart/orm
|
||||||
|
|
Loading…
Reference in a new issue