fastly_nsq 1.14.0 → 1.15.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/ChangeLog.md +8 -1
- data/README.md +1 -0
- data/lib/fastly_nsq.rb +11 -0
- data/lib/fastly_nsq/feeder.rb +1 -1
- data/lib/fastly_nsq/manager.rb +3 -3
- data/lib/fastly_nsq/version.rb +1 -1
- data/spec/manager_spec.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 135337a9892fdb4e0ddb5d448cae0f9d298b66a3a1a2d53966b9ba1c3c31d734
|
4
|
+
data.tar.gz: 103ab244297b6e29b0f50fdda88881cbe030943b2d019dcf31f9080203b8d36b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 948bd9896a2709c88b2dffdfc8fa13de42d8f0d46f62c8cd635ff4323dd57a2be75cb805598a6878059a7416aa5e78f719cd4d026462833fe609168a46e8ebd9
|
7
|
+
data.tar.gz: 299eb6013dc14fd5f7fc84e752d75b60c633883e60517b9f507e7247bca4d6bb0a2ca4825cffc8b3836697208e76cac464a83ec25bda5119b852c724b25b82bc
|
data/ChangeLog.md
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
## [v1.
|
3
|
+
## [v1.15.0](https://github.com/fastly/fastly_nsq/tree/v1.15.0)
|
4
4
|
|
5
|
+
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v1.14.0...v1.15.0)
|
6
|
+
|
7
|
+
**Merged pull requests:**
|
8
|
+
|
9
|
+
- Add support for configuring max\_threads [\#94](https://github.com/fastly/fastly_nsq/pull/94) ([leklund](https://github.com/leklund))
|
10
|
+
|
11
|
+
## [v1.14.0](https://github.com/fastly/fastly_nsq/tree/v1.14.0) (2018-08-13)
|
5
12
|
[Full Changelog](https://github.com/fastly/fastly_nsq/compare/v1.13.1...v1.14.0)
|
6
13
|
|
7
14
|
**Merged pull requests:**
|
data/README.md
CHANGED
@@ -159,6 +159,7 @@ FastlyNsq.configure do |config|
|
|
159
159
|
|
160
160
|
config.max_attempts = 20
|
161
161
|
config.max_req_timeout = (60 * 60 * 4 * 1_000) # 4 hours
|
162
|
+
config.max_processing_pool_threads = 10
|
162
163
|
|
163
164
|
lc.listen 'posts', ->(m) { puts "posts: #{m.body}" }
|
164
165
|
lc.listen 'blogs', ->(m) { puts "blogs: #{m.body}" }, priority: 3
|
data/lib/fastly_nsq.rb
CHANGED
@@ -30,6 +30,10 @@ module FastlyNsq
|
|
30
30
|
# @return [Integer]
|
31
31
|
attr_writer :max_req_timeout
|
32
32
|
|
33
|
+
# Maximum number of threads for FastlyNsq::PriorityThreadPool
|
34
|
+
# @return [Integer]
|
35
|
+
attr_writer :max_processing_pool_threads
|
36
|
+
|
33
37
|
##
|
34
38
|
# Map of lifecycle events
|
35
39
|
# @return [Hash]
|
@@ -111,6 +115,13 @@ module FastlyNsq
|
|
111
115
|
@max_req_timeout ||= ENV.fetch('MAX_REQ_TIMEOUT', 60 * 60 * 1_000).to_i
|
112
116
|
end
|
113
117
|
|
118
|
+
# Maximum number of threads for FastlyNsq::PriorityThreadPool
|
119
|
+
# Default setting is 5 and can be set via ENV['MAX_PROCESSING_POOL_THREADS']
|
120
|
+
# @return [Integer]
|
121
|
+
def max_processing_pool_threads
|
122
|
+
@max_processing_pool_threads ||= ENV.fetch('MAX_PROCESSING_POOL_THREADS', 5).to_i
|
123
|
+
end
|
124
|
+
|
114
125
|
##
|
115
126
|
# Return an array of NSQ lookupd http addresses sourced from ENV['NSQLOOKUPD_HTTP_ADDRESS']
|
116
127
|
# @return [Array<String>] list of nsqlookupd http addresses
|
data/lib/fastly_nsq/feeder.rb
CHANGED
@@ -32,7 +32,7 @@ class FastlyNsq::Feeder
|
|
32
32
|
# swallow the exception.
|
33
33
|
#
|
34
34
|
# @param message [Nsq::Message]
|
35
|
-
# @see http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/ThreadPoolExecutor.html#post-instance_method
|
35
|
+
# @see http://ruby-concurrency.github.io/concurrent-ruby/1.0.5/Concurrent/ThreadPoolExecutor.html#post-instance_method
|
36
36
|
# @see Nsq::Connection#read_loop
|
37
37
|
def push(message)
|
38
38
|
FastlyNsq.manager.pool.post(priority) do
|
data/lib/fastly_nsq/manager.rb
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
# Interface for tracking listeners and managing the processing pool.
|
5
5
|
class FastlyNsq::Manager
|
6
6
|
DEADLINE = 30
|
7
|
-
DEFAULT_POOL_SIZE = 5
|
8
7
|
|
9
8
|
# @return [Boolean] Set true when all listeners are stopped
|
10
9
|
attr_reader :done
|
@@ -19,12 +18,13 @@ class FastlyNsq::Manager
|
|
19
18
|
# Create a FastlyNsq::Manager
|
20
19
|
#
|
21
20
|
# @param logger [Logger]
|
21
|
+
# @param max_threads [Integer] Maxiumum number of threads to be used by {FastlyNsq::PriorityThreadPool}
|
22
22
|
# @param pool_options [Hash] Options forwarded to {FastlyNsq::PriorityThreadPool} constructor.
|
23
|
-
def initialize(logger: FastlyNsq.logger, **pool_options)
|
23
|
+
def initialize(logger: FastlyNsq.logger, max_threads: FastlyNsq.max_processing_pool_threads, **pool_options)
|
24
24
|
@done = false
|
25
25
|
@logger = logger
|
26
26
|
@pool = FastlyNsq::PriorityThreadPool.new(
|
27
|
-
{ fallback_policy: :caller_runs, max_threads:
|
27
|
+
{ fallback_policy: :caller_runs, max_threads: max_threads }.merge(pool_options),
|
28
28
|
)
|
29
29
|
end
|
30
30
|
|
data/lib/fastly_nsq/version.rb
CHANGED
data/spec/manager_spec.rb
CHANGED
@@ -16,14 +16,14 @@ RSpec.describe FastlyNsq::Manager do
|
|
16
16
|
|
17
17
|
describe '#initialize' do
|
18
18
|
it 'allows max_threads to be specified' do
|
19
|
-
max_threads =
|
19
|
+
max_threads = FastlyNsq.max_processing_pool_threads * 2
|
20
20
|
manager = described_class.new(max_threads: max_threads)
|
21
21
|
|
22
22
|
expect(manager.pool.max_threads).to eq(max_threads)
|
23
23
|
end
|
24
24
|
|
25
|
-
it 'defaults max_threads to
|
26
|
-
expect(subject.pool.max_threads).to eq(
|
25
|
+
it 'defaults max_threads to FastlyNsq.max_processing_pool_threads' do
|
26
|
+
expect(subject.pool.max_threads).to eq(FastlyNsq.max_processing_pool_threads)
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'allows fallback_policy to be specified' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastly_nsq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tommy O'Neil
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2018-
|
16
|
+
date: 2018-10-05 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: awesome_print
|
@@ -270,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
270
270
|
version: '0'
|
271
271
|
requirements: []
|
272
272
|
rubyforge_project:
|
273
|
-
rubygems_version: 2.7.
|
273
|
+
rubygems_version: 2.7.6
|
274
274
|
signing_key:
|
275
275
|
specification_version: 4
|
276
276
|
summary: Fastly NSQ Adapter
|