mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
remove connection from pool if explicitly closed
This commit is contained in:
parent
ea2a107069
commit
a62c90d092
2 changed files with 9 additions and 3 deletions
|
@ -38,6 +38,7 @@ module DB
|
|||
protected def do_close
|
||||
@statements_cache.each_value &.close
|
||||
@statements_cache.clear
|
||||
@database.pool.delete self
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -88,8 +88,7 @@ module DB
|
|||
rescue e : ConnectionLost
|
||||
# if the connection is lost close it to release resources
|
||||
# and remove it from the known pool.
|
||||
@total.delete(e.connection)
|
||||
@available.delete(e.connection)
|
||||
delete(e.connection)
|
||||
e.connection.close
|
||||
end
|
||||
end
|
||||
|
@ -103,11 +102,17 @@ module DB
|
|||
end
|
||||
end
|
||||
|
||||
# :nodon:
|
||||
# :nodoc:
|
||||
def is_available?(resource : T)
|
||||
@available.includes?(resource)
|
||||
end
|
||||
|
||||
# :nodoc:
|
||||
def delete(resource : T)
|
||||
@total.delete(resource)
|
||||
@available.delete(resource)
|
||||
end
|
||||
|
||||
private def build_resource : T
|
||||
resource = @factory.call
|
||||
@total << resource
|
||||
|
|
Loading…
Reference in a new issue