protobuf-activerecord 3.3.5 → 3.3.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6eb619048fc322fd28447c597d45c2b640f9de25
4
- data.tar.gz: 2c964967c403700a0fc10050c2d366be88a1767e
3
+ metadata.gz: 1edb2561d3b5957204fec48bb4ea3fa0d1a20a8c
4
+ data.tar.gz: da45242b3494982173f4058fb28950d9054c2289
5
5
  SHA512:
6
- metadata.gz: d50153357f7874cbff551c4f80a1ce37cc05b2fbfc484a13bae35b0c46ce950f2d6718d9a5c09d21647216cf10295d1a9a62b37f10c8cb0e4a0c16f98d236645
7
- data.tar.gz: e864f028ee4a138ae78f2e0930a4fe32a999147c7ef5b4cb00f8871600646ff98b99a3b7ce3063212e9e9844e23df57e1a310837e1ef0acf8d1b18f97b1c84fd
6
+ metadata.gz: 3ad12a5f32846341399c3ba0d2f74f5aed05949864dcf0c90945382c827db6345a7ebfe399f6ef7bf1038ec556f7693fbbe2c350d54f488c14372115d5436ed0
7
+ data.tar.gz: 8003d794964acdd6c174e6b632e6d42f2d58d2886581f0ad18c7c8e15a33ff0bbb8db2a310a908485cebb80694ee7dcbe0cbeb185019a17d99233d63078b15ad
@@ -13,6 +13,7 @@ end
13
13
 
14
14
  require 'protobuf/active_record/config'
15
15
  require 'protobuf/active_record/middleware/connection_management'
16
+ require 'protobuf/active_record/middleware/connection_management_async'
16
17
  require 'protobuf/active_record/middleware/query_cache'
17
18
  require 'protobuf/active_record/model'
18
19
  require 'protobuf/active_record/version'
@@ -5,6 +5,8 @@ module Protobuf
5
5
  super
6
6
 
7
7
  self[:autoload] = true
8
+ self[:connection_reaping_interval] = 6
9
+ self[:connection_reaping_timeout_interval] = 5
8
10
  end
9
11
  end
10
12
  end
@@ -0,0 +1,53 @@
1
+ require "concurrent"
2
+ require "thread"
3
+
4
+ module Protobuf
5
+ module ActiveRecord
6
+ module Middleware
7
+ class ConnectionManagementAsync
8
+ START_MUTEX = ::Mutex.new
9
+
10
+ def self.start_timed_task!
11
+ if timed_task_started.false?
12
+ START_MUTEX.synchronize do
13
+ return if timed_task_started.true?
14
+
15
+ timed_task = ::Concurrent::TimerTask.new(
16
+ :execution_interval => ::Protobuf::ActiveRecord.config.connection_reaping_interval,
17
+ :timeout_interval => ::Protobuf::ActiveRecord.config.connection_reaping_timeout_interval) do
18
+
19
+ ::ActiveRecord::Base.clear_active_connections!
20
+ end
21
+
22
+ timed_task.execute
23
+ timed_task_started.make_true
24
+ end
25
+ end
26
+ end
27
+
28
+ def self.timed_task_started
29
+ if @timed_task_started.nil?
30
+ @timed_task_started = ::Concurrent::AtomicBoolean.new(false)
31
+ end
32
+
33
+ @timed_task_started
34
+ end
35
+
36
+ def initialize(app)
37
+ @app = app
38
+ end
39
+
40
+ def call(env)
41
+ def call(env)
42
+ @app.call(env)
43
+ end
44
+
45
+ self.class.start_timed_task!
46
+ call(env)
47
+ end
48
+
49
+ timed_task_started
50
+ end
51
+ end
52
+ end
53
+ end
@@ -1,5 +1,5 @@
1
1
  module Protobuf
2
2
  module ActiveRecord
3
- VERSION = "3.3.5"
3
+ VERSION = "3.3.6"
4
4
  end
5
5
  end
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
  #
24
24
  spec.add_dependency "activerecord", "~> 4.2"
25
25
  spec.add_dependency "activesupport", ">= 3.2"
26
+ spec.add_dependency "concurrent-ruby"
26
27
  spec.add_dependency "heredity", ">= 0.1.1"
27
28
  spec.add_dependency "protobuf", ">= 3.0"
28
29
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protobuf-activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.5
4
+ version: 3.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Hutchison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-08 00:00:00.000000000 Z
11
+ date: 2017-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: concurrent-ruby
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: heredity
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -188,6 +202,7 @@ files:
188
202
  - lib/protobuf/active_record/mass_assignment_security/persistence.rb
189
203
  - lib/protobuf/active_record/mass_assignment_security/transformation.rb
190
204
  - lib/protobuf/active_record/middleware/connection_management.rb
205
+ - lib/protobuf/active_record/middleware/connection_management_async.rb
191
206
  - lib/protobuf/active_record/middleware/query_cache.rb
192
207
  - lib/protobuf/active_record/model.rb
193
208
  - lib/protobuf/active_record/nested_attributes.rb