Skip to content

Commit 69da56d

Browse files
committed
Allow to release connection
1 parent 2b61f77 commit 69da56d

1 file changed

Lines changed: 1 addition & 17 deletions

File tree

Sources/MySQLBridge/MySQLBridge.swift

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,7 @@ final class _MySQLBridge: Bridgeable {
5151
func connection<T>(to db: DatabaseIdentifier,
5252
on eventLoop: EventLoop,
5353
_ closure: @escaping (MySQLConnection) -> EventLoopFuture<T>) -> EventLoopFuture<T> {
54-
self.db(db, on: eventLoop).withConnection { conn in
55-
closure(conn).flatMap { result in
56-
if conn.isClosed {
57-
return conn.eventLoop.future(result)
58-
} else {
59-
return conn.close().transform(to: result)
60-
}
61-
}.flatMapError { error in
62-
if conn.isClosed {
63-
return conn.close().flatMapThrowing {
64-
throw error
65-
}
66-
} else {
67-
return conn.eventLoop.makeFailedFuture(error)
68-
}
69-
}
70-
}
54+
self.db(db, on: eventLoop).withConnection { closure($0) }
7155
}
7256

7357
func db(_ db: DatabaseIdentifier, on eventLoop: EventLoop) -> MySQLDatabase {

0 commit comments

Comments
 (0)