Skip to content

Commit

Permalink
Merge pull request #135 from wallyqs/add-jruby-lang
Browse files Browse the repository at this point in the history
Add jruby lang identifier on connect command
  • Loading branch information
Waldemar Quevedo committed Mar 3, 2017
2 parents 9125572 + 564fbc4 commit a0bd320
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
7 changes: 3 additions & 4 deletions lib/nats/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

module NATS

PROTOCOL_VERSION = 1
DEFAULT_PORT = 4222
DEFAULT_URI = "nats://localhost:#{DEFAULT_PORT}".freeze

Expand Down Expand Up @@ -519,9 +518,9 @@ def connect_command #:nodoc:
cs = {
:verbose => @options[:verbose],
:pedantic => @options[:pedantic],
:lang => :ruby,
:version => VERSION,
:protocol => PROTOCOL_VERSION
:lang => ::NATS::LANG,
:version => ::NATS::VERSION,
:protocol => ::NATS::PROTOCOL_VERSION
}
if auth_connection?
cs[:user] = @uri.user
Expand Down
5 changes: 4 additions & 1 deletion lib/nats/version.rb
Original file line number Diff line number Diff line change
@@ -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_ENGINE
PROTOCOL_VERSION = 1
end
4 changes: 2 additions & 2 deletions spec/client/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit a0bd320

Please sign in to comment.