mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
Bump required Crystal to 0.35.0 (#135)
In order to use logging we need 0.35.0
This commit is contained in:
parent
7253551849
commit
284145138f
2 changed files with 10 additions and 55 deletions
|
@ -4,6 +4,6 @@ version: 0.9.0
|
||||||
authors:
|
authors:
|
||||||
- Brian J. Cardiff <bcardiff@manas.tech>
|
- Brian J. Cardiff <bcardiff@manas.tech>
|
||||||
|
|
||||||
crystal: 0.25.0
|
crystal: 0.35.0
|
||||||
|
|
||||||
license: MIT
|
license: MIT
|
||||||
|
|
|
@ -229,7 +229,6 @@ module DB
|
||||||
@idle.first?
|
@idle.first?
|
||||||
end
|
end
|
||||||
|
|
||||||
{% if compare_versions(Crystal::VERSION, "0.34.0-0") > 0 %}
|
|
||||||
private def wait_for_available
|
private def wait_for_available
|
||||||
sync_inc_waiting_resource
|
sync_inc_waiting_resource
|
||||||
|
|
||||||
|
@ -241,26 +240,6 @@ module DB
|
||||||
raise DB::PoolTimeout.new("Could not check out a connection in #{@checkout_timeout} seconds")
|
raise DB::PoolTimeout.new("Could not check out a connection in #{@checkout_timeout} seconds")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
{% else %}
|
|
||||||
private def wait_for_available
|
|
||||||
timeout = TimeoutHelper.new(@checkout_timeout.to_f64)
|
|
||||||
sync_inc_waiting_resource
|
|
||||||
|
|
||||||
timeout.start
|
|
||||||
|
|
||||||
index, _ = Channel.select(@availability_channel.receive_select_action, timeout.receive_select_action)
|
|
||||||
case index
|
|
||||||
when 0
|
|
||||||
timeout.cancel
|
|
||||||
sync_dec_waiting_resource
|
|
||||||
when 1
|
|
||||||
sync_dec_waiting_resource
|
|
||||||
raise DB::PoolTimeout.new("Could not check out a connection in #{@checkout_timeout} seconds")
|
|
||||||
else
|
|
||||||
raise DB::Error.new
|
|
||||||
end
|
|
||||||
end
|
|
||||||
{% end %}
|
|
||||||
|
|
||||||
private def sync_inc_waiting_resource
|
private def sync_inc_waiting_resource
|
||||||
sync { @waiting_resource += 1 }
|
sync { @waiting_resource += 1 }
|
||||||
|
@ -291,29 +270,5 @@ module DB
|
||||||
@mutex.lock
|
@mutex.lock
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class TimeoutHelper
|
|
||||||
def initialize(@timeout : Float64)
|
|
||||||
@abort_timeout = false
|
|
||||||
@timeout_channel = Channel(Nil).new
|
|
||||||
end
|
|
||||||
|
|
||||||
def receive_select_action
|
|
||||||
@timeout_channel.receive_select_action
|
|
||||||
end
|
|
||||||
|
|
||||||
def start
|
|
||||||
spawn do
|
|
||||||
sleep @timeout
|
|
||||||
unless @abort_timeout
|
|
||||||
@timeout_channel.send nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def cancel
|
|
||||||
@abort_timeout = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue