activerecord-pgtimeout 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/activerecord/pgtimeout.rb +4 -5
- data/lib/activerecord/pgtimeout/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 158e3ddbec50c9abc515e46ce2f91b01295e7042
|
4
|
+
data.tar.gz: 0e66620adaaf2ff965598011dfec3894768c05bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40de913461dc49a6ce2174710a90ef2c3355aa4c77a914ae13912c10d95bcbad690cb5a07d99a62e0dfb5c9b5627f17c5669d46bcac4796fce3d952f3c1de40b
|
7
|
+
data.tar.gz: bc3b384b58b9cd5ee0a439535d7cb3e9ee841aec5a12ec2740141968b5b9e6d78e248eb5c4647718777fad5b7aeeb39ef5b1fa8dd58cb347fa9b3a2661d3e41d
|
@@ -4,14 +4,13 @@ module ActiveRecord
|
|
4
4
|
class PgTimeout
|
5
5
|
attr_reader :timeout
|
6
6
|
|
7
|
-
def initialize(timeout
|
8
|
-
@connection = connection
|
7
|
+
def initialize(timeout)
|
9
8
|
@timeout = timeout
|
10
9
|
end
|
11
10
|
|
12
|
-
def execute(timeoutable_action, on_timeout)
|
13
|
-
|
14
|
-
|
11
|
+
def execute(timeoutable_action, on_timeout, connection = ActiveRecord::Base.connection)
|
12
|
+
connection.transaction do
|
13
|
+
connection.execute("set local statement_timeout to '#{timeout.to_i}ms'")
|
15
14
|
timeoutable_action.()
|
16
15
|
end
|
17
16
|
|