nsq-ruby 2.3.0 → 2.4.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
  SHA256:
3
- metadata.gz: 6c931ee31ebc9745dba9e2084740d6022f97b0ef280d1661cc1391910481eee9
4
- data.tar.gz: '0965ea14b66ebfa6d1ca429af3cab05f970418f5cd41241362619b1e19444a08'
3
+ metadata.gz: e4e154c268c869f718aa9942e54f23dc6d62b7299ac26a1facb91f7f5d6d324c
4
+ data.tar.gz: 164655c96eb9730b5396c1b50000378fabf4f9e97c54dff358f33bcff6c0e7dc
5
5
  SHA512:
6
- metadata.gz: 67e99a8a1b6051325fd04e56bda7910eb41f46a39bf9baf9969bbfa8b04af5b9a6fc2297f707eb1ffdbb4a257a138112532639662a4e484ec47608ba93bdbcb9
7
- data.tar.gz: bec66cc5f0990f97d55551b0b786ad0043c70d0dbe14e6b728726bbbdbd551caaac012adc5bf3d699113c3f11e9e9885ca579be41c9d7bcc205d7326f90d68ec
6
+ metadata.gz: f89d563ed42364550a1a301040e78ea758e563c0f867404b3d11b25f0d54917e10abfa754018c2d940fcc193dae3475e6e164544b7a141c67136e8a0d29fff68
7
+ data.tar.gz: 1b4400f790a5c16c07dd34d58e468a11e71c2026eb0567dba0584bac20d2cbe9beb227a897b69832ae0774e405cad064ed65cf318b74414ac62cf2c165586216
data/README.md CHANGED
@@ -17,7 +17,7 @@ nsq-ruby is a simple NSQ client library written in Ruby.
17
17
  ```Ruby
18
18
  require 'nsq'
19
19
  producer = Nsq::Producer.new(
20
- nsqd: '127.0.0.1:4150',
20
+ nsqd: '127.0.0.1:4150', # or ['127.0.0.1:4150']
21
21
  topic: 'some-topic'
22
22
  )
23
23
 
@@ -77,7 +77,7 @@ For example, if you'd like to publish messages to a single nsqd.
77
77
 
78
78
  ```Ruby
79
79
  producer = Nsq::Producer.new(
80
- nsqd: '6.7.8.9:4150',
80
+ nsqd: '6.7.8.9:4150', # or ['6.7.8.9:4150']
81
81
  topic: 'topic-of-great-esteem'
82
82
  )
83
83
  ```
@@ -177,6 +177,14 @@ reconnect.
177
177
  This is automatically called `at_exit`, but it's good practice to close your
178
178
  producers when you're done with them.
179
179
 
180
+ **Note:** This terminates the connection to NSQ immediately. If you're writing
181
+ messages faster than they can be sent to NSQ, you may have messages in the
182
+ producer's internal queue. Calling `#terminate` before they're sent will cause
183
+ these messages to be lost. After you write your last message, consider sleeping
184
+ for a second before you call `#terminate`.
185
+
186
+
187
+
180
188
 
181
189
  ## Consumer
182
190
 
@@ -391,7 +399,7 @@ millions of messages a day.
391
399
 
392
400
  ## MIT License
393
401
 
394
- Copyright (C) 2016 Wistia, Inc.
402
+ Copyright (C) 2018 Wistia, Inc.
395
403
 
396
404
  Permission is hereby granted, free of charge, to any person obtaining a copy of
397
405
  this software and associated documentation files (the "Software"), to deal in
@@ -410,4 +418,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
410
418
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
411
419
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
412
420
  SOFTWARE.
413
-
data/lib/nsq/consumer.rb CHANGED
@@ -27,7 +27,7 @@ module Nsq
27
27
 
28
28
  # This is where we keep a record of our active nsqd connections
29
29
  # The key is a string with the host and port of the instance (e.g.
30
- # '127.0.0.1:4150') and the key is the Connection instance.
30
+ # '127.0.0.1:4150') and the value is the Connection instance.
31
31
  @connections = {}
32
32
 
33
33
  if !@nsqlookupds.empty?
@@ -36,10 +36,14 @@ module Nsq
36
36
  topic: @topic,
37
37
  interval: @discovery_interval
38
38
  )
39
+
40
+ elsif opts[:nsqd]
41
+ nsqds = [opts[:nsqd]].flatten
42
+ max_per_conn = max_in_flight_per_connection(nsqds.size)
43
+ nsqds.each{|d| add_connection(d, max_in_flight: max_per_conn)}
44
+
39
45
  else
40
- # normally, we find nsqd instances to connect to via nsqlookupd(s)
41
- # in this case let's connect to an nsqd instance directly
42
- add_connection(opts[:nsqd] || '127.0.0.1:4150', max_in_flight: @max_in_flight)
46
+ add_connection('127.0.0.1:4150', max_in_flight: @max_in_flight)
43
47
  end
44
48
  end
45
49
 
data/lib/nsq/discovery.rb CHANGED
@@ -70,7 +70,7 @@ module Nsq
70
70
  uri.query = "ts=#{Time.now.to_i}"
71
71
  if topic
72
72
  uri.path = '/lookup'
73
- uri.query += "&topic=#{URI.escape(topic)}"
73
+ uri.query += "&topic=#{URI.encode_www_form_component(topic)}"
74
74
  else
75
75
  uri.path = '/nodes'
76
76
  end
@@ -9,7 +9,7 @@ module Nsq
9
9
 
10
10
  def initialize(data, connection)
11
11
  super
12
- @timestamp_in_nanoseconds, @attempts, @id, @body = @data.unpack('Q>s>a16a*')
12
+ @timestamp_in_nanoseconds, @attempts, @id, @body = @data.unpack('Q>S>a16a*')
13
13
  @body.force_encoding('UTF-8')
14
14
  end
15
15
 
data/lib/version.rb CHANGED
@@ -2,7 +2,7 @@ module Nsq
2
2
  module Version
3
3
  MAJOR = 2
4
4
  MINOR = 3
5
- PATCH = 0
5
+ PATCH = 1
6
6
  BUILD = nil
7
7
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,43 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nsq-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wistia
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-01 00:00:00.000000000 Z
11
+ date: 2018-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.0'
27
- - !ruby/object:Gem::Dependency
28
- name: jeweler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '2.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '2.0'
41
13
  - !ruby/object:Gem::Dependency
42
14
  name: nsq-cluster
43
15
  requirement: !ruby/object:Gem::Requirement
@@ -93,7 +65,7 @@ homepage: http://github.com/wistia/nsq-ruby
93
65
  licenses:
94
66
  - MIT
95
67
  metadata: {}
96
- post_install_message:
68
+ post_install_message:
97
69
  rdoc_options: []
98
70
  require_paths:
99
71
  - lib
@@ -108,9 +80,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
80
  - !ruby/object:Gem::Version
109
81
  version: '0'
110
82
  requirements: []
111
- rubyforge_project:
112
- rubygems_version: 2.7.6
113
- signing_key:
83
+ rubygems_version: 3.1.6
84
+ signing_key:
114
85
  specification_version: 4
115
86
  summary: Ruby client library for NSQ
116
87
  test_files: []