circuitry 1.2.3 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.codeclimate.yml +9 -0
- data/README.md +10 -0
- data/lib/circuitry/configuration.rb +2 -0
- data/lib/circuitry/processors/forker.rb +5 -1
- data/lib/circuitry/processors/threader.rb +5 -1
- data/lib/circuitry/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9183d64596ee7f88393c7ef2a9469e493622dbd
|
4
|
+
data.tar.gz: fbf9569e2e8d3ee9c55693decebc6a60b2aff295
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a6fb3550295bdada1eb956aa8fc15ea46db14cf35ec19bcdbf0c5521bbfe6a9f0a87395ed000c1f5f53dec492feba389c703b0e46115af280184f096b778403
|
7
|
+
data.tar.gz: e84272270e33d8ca0eee876df181666b37dea65b0c361ef3379aa748d857632f6257909509d20a205f2e01d4811d8ec624cc1c0dfe254c99584b37ebede604ba
|
data/.codeclimate.yml
ADDED
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
|
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
|
-
|
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
|
data/lib/circuitry/version.rb
CHANGED
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.
|
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-
|
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
|