mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
Add connection retry logic to connection pool
This commit is contained in:
parent
dbf7c94ef4
commit
47e7d826e8
8 changed files with 102 additions and 9 deletions
|
@ -9,6 +9,7 @@ class DummyDriver < DB::Driver
|
|||
class DummyConnection < DB::Connection
|
||||
def initialize(db)
|
||||
super(db)
|
||||
@connected = true
|
||||
@@connections ||= [] of DummyConnection
|
||||
@@connections.not_nil! << self
|
||||
end
|
||||
|
@ -29,6 +30,14 @@ class DummyDriver < DB::Driver
|
|||
0
|
||||
end
|
||||
|
||||
def check
|
||||
raise DB::ConnectionLost.new(self) unless @connected
|
||||
end
|
||||
|
||||
def disconnect!
|
||||
@connected = false
|
||||
end
|
||||
|
||||
protected def do_close
|
||||
super
|
||||
end
|
||||
|
@ -43,11 +52,13 @@ class DummyDriver < DB::Driver
|
|||
end
|
||||
|
||||
protected def perform_query(args : Enumerable)
|
||||
@connection.as(DummyConnection).check
|
||||
set_params args
|
||||
DummyResultSet.new self, @query
|
||||
end
|
||||
|
||||
protected def perform_exec(args : Enumerable)
|
||||
@connection.as(DummyConnection).check
|
||||
set_params args
|
||||
raise "forced exception due to query" if @query == "raise"
|
||||
DB::ExecResult.new 0i64, 0_i64
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue