From bab5c487d34be9d228e4da4468974203d7ad7eb1 Mon Sep 17 00:00:00 2001 From: Waldemar Quevedo Date: Fri, 18 Nov 2016 14:01:45 -0800 Subject: [PATCH 1/3] Add jruby as lang on connect --- lib/nats/client.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/nats/client.rb b/lib/nats/client.rb index be527a68..ce3db578 100644 --- a/lib/nats/client.rb +++ b/lib/nats/client.rb @@ -519,10 +519,17 @@ def connect_command #:nodoc: cs = { :verbose => @options[:verbose], :pedantic => @options[:pedantic], - :lang => :ruby, :version => VERSION, :protocol => PROTOCOL_VERSION } + + case RUBY_PLATFORM + when "java" + cs[:lang] = :jruby + else + cs[:lang] = :ruby + end + if auth_connection? cs[:user] = @uri.user cs[:pass] = @uri.password From cfd70472abfbf7c08f83ccdaa925398807e84f81 Mon Sep 17 00:00:00 2001 From: Waldemar Quevedo Date: Fri, 18 Nov 2016 16:27:33 -0800 Subject: [PATCH 2/3] Update connect command send on tests --- lib/nats/client.rb | 14 +++----------- lib/nats/version.rb | 5 ++++- spec/client/client_spec.rb | 4 ++-- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/nats/client.rb b/lib/nats/client.rb index ce3db578..1ddeccd6 100644 --- a/lib/nats/client.rb +++ b/lib/nats/client.rb @@ -10,7 +10,6 @@ module NATS - PROTOCOL_VERSION = 1 DEFAULT_PORT = 4222 DEFAULT_URI = "nats://localhost:#{DEFAULT_PORT}".freeze @@ -519,17 +518,10 @@ def connect_command #:nodoc: cs = { :verbose => @options[:verbose], :pedantic => @options[:pedantic], - :version => VERSION, - :protocol => PROTOCOL_VERSION + :lang => ::NATS::LANG, + :version => ::NATS::VERSION, + :protocol => ::NATS::PROTOCOL_VERSION } - - case RUBY_PLATFORM - when "java" - cs[:lang] = :jruby - else - cs[:lang] = :ruby - end - if auth_connection? cs[:user] = @uri.user cs[:pass] = @uri.password diff --git a/lib/nats/version.rb b/lib/nats/version.rb index 3993dbc1..842ba1dc 100644 --- a/lib/nats/version.rb +++ b/lib/nats/version.rb @@ -1,3 +1,6 @@ module NATS - VERSION = "0.8.0".freeze + # NOTE: These are all announced to the server on CONNECT + VERSION = "0.8.2".freeze + LANG = (RUBY_PLATFORM == 'java' ? 'jruby' : 'ruby').freeze + PROTOCOL_VERSION = 1 end diff --git a/spec/client/client_spec.rb b/spec/client/client_spec.rb index e2772f79..b1180d7f 100644 --- a/spec/client/client_spec.rb +++ b/spec/client/client_spec.rb @@ -393,14 +393,14 @@ def c.send_ping it 'should allowing setting name for the client on connect' do with_em_timeout do - connect_command = "CONNECT {\"verbose\":false,\"pedantic\":false,\"lang\":\"ruby\",\"version\":\"#{NATS::VERSION}\",\"protocol\":1,\"name\":\"hello\"}\r\n" + connect_command = "CONNECT {\"verbose\":false,\"pedantic\":false,\"lang\":\"#{NATS::LANG}\",\"version\":\"#{NATS::VERSION}\",\"protocol\":#{NATS::PROTOCOL_VERSION},\"name\":\"hello\"}\r\n" conn = NATS.connect(:name => "hello") expect(conn.connect_command).to eql(connect_command) end end it 'should not repeat SUB commands when connecting' do - pending_commands = "CONNECT {\"verbose\":false,\"pedantic\":true,\"lang\":\"ruby\",\"version\":\"#{NATS::VERSION}\",\"protocol\":1}\r\n" + pending_commands = "CONNECT {\"verbose\":false,\"pedantic\":true,\"lang\":\"#{NATS::LANG}\",\"version\":\"#{NATS::VERSION}\",\"protocol\":#{NATS::PROTOCOL_VERSION}}\r\n" pending_commands += "PING\r\n" pending_commands += "SUB hello 2\r\nSUB hello 3\r\nSUB hello 4\r\nSUB hello 5\r\nSUB hello 6\r\n" From 564fbc4bf60d22b79b93ac9803be3a7db4bf4ee7 Mon Sep 17 00:00:00 2001 From: Waldemar Quevedo Date: Thu, 2 Mar 2017 16:44:34 -0800 Subject: [PATCH 3/3] Use RUBY_ENGINE when announcing runtime on CONNECT --- lib/nats/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nats/version.rb b/lib/nats/version.rb index 842ba1dc..60787dcc 100644 --- a/lib/nats/version.rb +++ b/lib/nats/version.rb @@ -1,6 +1,6 @@ module NATS # NOTE: These are all announced to the server on CONNECT VERSION = "0.8.2".freeze - LANG = (RUBY_PLATFORM == 'java' ? 'jruby' : 'ruby').freeze + LANG = RUBY_ENGINE PROTOCOL_VERSION = 1 end