circuitry 1.2.3 → 1.3.0

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: 9152102b3b0bcb0241791c11c0f6cdb4f10c4d1a
4
- data.tar.gz: 8fa3e884159dfb1ba1511190ddaee6fc4a7773d9
3
+ metadata.gz: e9183d64596ee7f88393c7ef2a9469e493622dbd
4
+ data.tar.gz: fbf9569e2e8d3ee9c55693decebc6a60b2aff295
5
5
  SHA512:
6
- metadata.gz: fbae0a7eeafb7c4a799a9ff8f7858fd81296e4e04dd717b47f2c0d75a7ac40690637d14d20331148be1879cf48355fae80a9c7d01b0ca81d30eb94a07e46e3c0
7
- data.tar.gz: cd4adfe1e83352755338c615bba2f4a0b9d39d6986500f5ca54fe39f55a0a56e6aa6233da37163a094ea6d3985447fc5eba10267d8ecb49d1ecaf484e0e69b8f
6
+ metadata.gz: 3a6fb3550295bdada1eb956aa8fc15ea46db14cf35ec19bcdbf0c5521bbfe6a9f0a87395ed000c1f5f53dec492feba389c703b0e46115af280184f096b778403
7
+ data.tar.gz: e84272270e33d8ca0eee876df181666b37dea65b0c361ef3379aa748d857632f6257909509d20a205f2e01d4811d8ec624cc1c0dfe254c99584b37ebede604ba
data/.codeclimate.yml ADDED
@@ -0,0 +1,9 @@
1
+ ---
2
+ engines:
3
+ rubocop:
4
+ enabled: true
5
+ ratings:
6
+ paths:
7
+ - "**.rb"
8
+ exclude_paths:
9
+ - spec/**/*
data/README.md CHANGED
@@ -39,6 +39,8 @@ Circuitry.config do |c|
39
39
  c.lock_strategy = Circuitry::Locks::Redis.new(url: 'redis://localhost:6379')
40
40
  c.publish_async_strategy = :batch
41
41
  c.subscribe_async_strategy = :thread
42
+ c.on_thread_exit = proc { Mongoid.disconnect_sessions }
43
+ c.on_fork_exit = proc { Mongoid.disconnect_sessions }
42
44
  end
43
45
  ```
44
46
 
@@ -73,6 +75,14 @@ Available configuration options include:
73
75
  queue.
74
76
  * `:thread`: Creates a new thread that immediately sends begins querying the
75
77
  queue.
78
+ * `on_thread_exit`: An object that responds to `call`. This is useful for
79
+ managing shared resources such as database connections that require closing.
80
+ It is only called when implementing the `:thread` async strategy. *(optional,
81
+ default: `nil`)*
82
+ * `on_fork_exit`: An object that responds to `call`. This is useful for
83
+ managing shared resources such as database connections that require closing,
84
+ It is only called when implementing the `:fork` async strategy. *(optional,
85
+ default: `nil`)*
76
86
 
77
87
  ### Publishing
78
88
 
@@ -13,6 +13,8 @@ module Circuitry
13
13
  attribute :lock_strategy, Object, default: ->(page, attribute) { Circuitry::Locks::Memory.new }
14
14
  attribute :publish_async_strategy, Symbol, default: ->(page, attribute) { :fork }
15
15
  attribute :subscribe_async_strategy, Symbol, default: ->(page, attribute) { :fork }
16
+ attribute :on_thread_exit
17
+ attribute :on_fork_exit
16
18
 
17
19
  def publish_async_strategy=(value)
18
20
  validate(value, Publisher.async_strategies)
@@ -7,7 +7,11 @@ module Circuitry
7
7
  include Processor
8
8
 
9
9
  def process(&block)
10
- pid = fork { safely_process(&block) }
10
+ pid = fork do
11
+ safely_process(&block)
12
+ Circuitry.config.on_fork_exit.call if Circuitry.config.on_fork_exit
13
+ end
14
+
11
15
  Process.detach(pid)
12
16
  end
13
17
 
@@ -8,7 +8,11 @@ module Circuitry
8
8
 
9
9
  def process(&block)
10
10
  raise ArgumentError, 'no block given' unless block_given?
11
- pool << Thread.new { safely_process(&block) }
11
+
12
+ pool << Thread.new do
13
+ safely_process(&block)
14
+ Circuitry.config.on_thread_exit.call if Circuitry.config.on_thread_exit
15
+ end
12
16
  end
13
17
 
14
18
  def flush
@@ -1,3 +1,3 @@
1
1
  module Circuitry
2
- VERSION = '1.2.3'
2
+ VERSION = '1.3.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: circuitry
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Huggins
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-26 00:00:00.000000000 Z
11
+ date: 2015-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-aws
@@ -185,6 +185,7 @@ executables: []
185
185
  extensions: []
186
186
  extra_rdoc_files: []
187
187
  files:
188
+ - ".codeclimate.yml"
188
189
  - ".gitignore"
189
190
  - ".rspec"
190
191
  - Gemfile