nats 0.7.1 → 0.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7ddc674e2fae7f2b90a23808e70653f03e83705
4
- data.tar.gz: 507e7fef7ae1d83b7d6d71582733c2dd117b2958
3
+ metadata.gz: c785185ca50a110f1e5097074eb94932875ec56f
4
+ data.tar.gz: fdf520606b0140c0ea01ecce19ef4a7a2e60c5fb
5
5
  SHA512:
6
- metadata.gz: 70075424ffa0204ff72290c67b934b68966d42fd6e7df080e2c2874525efbe56070391f31bb69fa643fc4726c52eabc1c736ef14471e49f7cb39a8f84b40cf54
7
- data.tar.gz: e7521de1ab5fb77210cafab68f8f3156afa06b8031d9a2eaf42f10656fa152242dd6b2cd0110dc21a11cd366481b5df6e10dc562e068eb0c2503b0e8442cd8b5
6
+ metadata.gz: 8caccc1be68f33b8a06385e002646ca4e9ac3bb8aea387f192a95d46978a84df8d28898f03f9b932bf9c0e7a0d9a6de9f4476041770f28b96be853f5b4fae3e1
7
+ data.tar.gz: 7f9280338f75b80a1088d2d5ac280efb239449de5a87987d3725883bd0257768cebb36b19ca9e2fe9b2d6e47a3be48494a73c16711e48e99a5bac672e107efb6
data/HISTORY.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # HISTORY
2
2
 
3
+ ## v0.7.1 (July 8, 2016)
4
+ - Remove dependencies which are no longer needed for ruby-client
5
+ - See full list @ https://github.com/nats-io/ruby-nats/compare/v0.7.0...v0.7.1
6
+
7
+ ## v0.7.0 (July 8, 2016)
8
+ - Enhanced TLS support: certificates and verify peer functionality added
9
+ - Bumped version of Eventmachine to 1.2 series
10
+ - See full list @ https://github.com/nats-io/ruby-nats/compare/v0.6.0...v0.7.0
11
+
3
12
  ## v0.6.0 (March 22, 2016)
4
13
  - Removed distributing `nats-server` along with the gem
5
14
  - Fixed issue with subscriptions not being sent on first reconnect (#94)
data/Rakefile CHANGED
@@ -2,17 +2,24 @@
2
2
  require 'rspec/core'
3
3
  require 'rspec/core/rake_task'
4
4
 
5
+ task :default => 'spec:client'
6
+
5
7
  desc 'Run specs from client and server'
6
8
  RSpec::Core::RakeTask.new(:spec) do |spec|
7
9
  spec.pattern = FileList['spec/**/*_spec.rb']
8
- spec.rspec_opts = ["--format", "documentation", "--colour"]
10
+ spec.rspec_opts = ["--format", "documentation", "--colour", "--profile"]
9
11
  end
10
- task :default => :spec
11
12
 
12
13
  desc 'Run spec from client using gnatsd as the server'
13
14
  RSpec::Core::RakeTask.new('spec:client') do |spec|
14
15
  spec.pattern = FileList['spec/client/*_spec.rb']
15
- spec.rspec_opts = ["--format", "documentation", "--colour"]
16
+ spec.rspec_opts = ["--format", "documentation", "--colour", "--profile"]
17
+ end
18
+
19
+ desc 'Run spec from client on jruby using gnatsd as the server'
20
+ RSpec::Core::RakeTask.new('spec:client:jruby') do |spec|
21
+ spec.pattern = FileList['spec/client/*_spec.rb']
22
+ spec.rspec_opts = ["--format", "documentation", "--colour", "--tag", "~jruby_excluded", "--profile"]
16
23
  end
17
24
 
18
25
  desc 'Run spec from server'
@@ -10,6 +10,7 @@ require "#{ep}/version"
10
10
 
11
11
  module NATS
12
12
 
13
+ PROTOCOL_VERSION = 1
13
14
  DEFAULT_PORT = 4222
14
15
  DEFAULT_URI = "nats://localhost:#{DEFAULT_PORT}".freeze
15
16
 
@@ -173,8 +174,10 @@ module NATS
173
174
  EM.epoll
174
175
  elsif EM.kqueue?
175
176
  EM.kqueue
177
+ elsif EM.library_type == :java
178
+ # No warning needed, we're using Java NIO
176
179
  else
177
- Kernel.warn('Neither epoll nor kqueue are supported')
180
+ Kernel.warn('Neither epoll nor kqueue are supported, performance may be impacted')
178
181
  end
179
182
  EM.run { @client = connect(*args, &blk) }
180
183
  end
@@ -241,7 +244,7 @@ module NATS
241
244
  end
242
245
 
243
246
  # Set the default on_closed callback.
244
- # @param [Block] &callback called when will reach a state when will no longer be connected.
247
+ # @param [Block] &callback called when will reach a state when will no longer be connected.
245
248
  def on_close(&callback)
246
249
  @close_cb = callback
247
250
  @client.on_close(&callback) unless @client.nil?
@@ -517,7 +520,8 @@ module NATS
517
520
  :verbose => @options[:verbose],
518
521
  :pedantic => @options[:pedantic],
519
522
  :lang => :ruby,
520
- :version => VERSION
523
+ :version => VERSION,
524
+ :protocol => PROTOCOL_VERSION
521
525
  }
522
526
  if auth_connection?
523
527
  cs[:user] = @uri.user
@@ -654,6 +658,37 @@ module NATS
654
658
  # Otherwise, use a regular connection.
655
659
  end
656
660
 
661
+ # Detect any announced server that we might not be aware of...
662
+ connect_urls = @server_info[:connect_urls]
663
+ if connect_urls
664
+ srvs = []
665
+
666
+ connect_urls.each do |url|
667
+ u = URI.parse("nats://#{url}")
668
+ present = server_pool.detect do |srv|
669
+ srv[:uri].host == u.host && srv[:uri].port == u.port
670
+ end
671
+
672
+ if not present
673
+ # Let explicit user and pass options set the credentials.
674
+ u.user = options[:user] if options[:user]
675
+ u.password = options[:pass] if options[:pass]
676
+
677
+ # Use creds from the current server if not set explicitly.
678
+ if @uri
679
+ u.user ||= @uri.user if @uri.user
680
+ u.password ||= @uri.password if @uri.password
681
+ end
682
+
683
+ srvs << { :uri => u, :reconnect_attempts => 0 }
684
+ end
685
+ end
686
+ srvs.shuffle! unless @options[:dont_randomize_servers]
687
+
688
+ # Include in server pool but keep current one as the first one.
689
+ server_pool.push(*srvs)
690
+ end
691
+
657
692
  if @server_info[:auth_required]
658
693
  current = server_pool.first
659
694
  current[:auth_required] = true
@@ -705,7 +740,7 @@ module NATS
705
740
  # Mark that we established already TCP connection to the server. In case of TLS,
706
741
  # prepare commands which will be dispatched to server and delay flushing until
707
742
  # we have processed the INFO line sent by the server and done the handshake.
708
- @connected = true
743
+ @connected = true
709
744
  process_connect
710
745
  end
711
746
 
@@ -714,7 +749,7 @@ module NATS
714
749
  process_connect
715
750
  end
716
751
 
717
- def process_connect #:nodoc:
752
+ def process_connect #:nodoc:
718
753
  # Reset reconnect attempts since TCP connection has been successful at this point.
719
754
  current = server_pool.first
720
755
  current[:was_connected] = true
@@ -759,12 +794,12 @@ module NATS
759
794
 
760
795
  def send_ping #:nodoc:
761
796
  return if @closing
797
+ @pings_outstanding += 1
762
798
  if @pings_outstanding > @options[:max_outstanding_pings]
763
799
  close_connection
764
800
  #close
765
801
  return
766
802
  end
767
- @pings_outstanding += 1
768
803
  queue_server_rt { process_pong }
769
804
  flush_pending
770
805
  end
@@ -1,3 +1,4 @@
1
+ require 'pp'
1
2
 
2
3
  def fast_uuid #:nodoc:
3
4
  v = [rand(0x0010000),rand(0x0010000),rand(0x0010000),
@@ -1,3 +1,3 @@
1
1
  module NATS
2
- VERSION = "0.7.1".freeze
2
+ VERSION = "0.8.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Collison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-08 00:00:00.000000000 Z
11
+ date: 2016-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine