Skip to content

Commit

Permalink
fixed connection releasing
Browse files Browse the repository at this point in the history
  • Loading branch information
dileping committed Mar 26, 2017
1 parent dbad29d commit a812404
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Sources/Swirl/Swirl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ public class SwirlManager {
_dialects[dialect.proto] = dialect
}

fileprivate func driver(url:String, params: [String: String]) throws -> SwirlDriver {
fileprivate func dialect(url:String, params: [String: String]) throws -> Dialect {
let driver = try _rdbc.driver(url: url, params: params)
guard let dialect = _dialects[driver.proto] else {
throw SwirlError.noDialect
}

return try SwirlDriver(driver: driver, dialect: dialect)
return dialect
}
}

Expand All @@ -108,6 +108,10 @@ public class Swirl {
_release = release
}

deinit {
_release()
}

convenience init(connection: Connection, dialect: Dialect) throws {
try self.init(connection: connection, dialect: dialect) {}
}
Expand Down Expand Up @@ -140,8 +144,8 @@ public class Swirl {

public extension SwirlManager {
public func swirl(url:String, params:[String: String] = [:]) throws -> Swirl {
let dialect = try driver(url: url, params: params).dialect
let pool = _rdbc.pool(url: url, params: params)
let dialect = try self.dialect(url: url, params: params)
let pool = try _rdbc.pool(url: url, params: params)
return try Swirl(connection: pool, dialect: dialect)
}
}

0 comments on commit a812404

Please sign in to comment.