nats 0.4.2 → 0.4.8

Sign up to get free protection for your applications and to get access to all the features.
data/COPYING CHANGED
@@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
16
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
17
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
18
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
- IN THE SOFTWARE.
19
+ IN THE SOFTWARE.
@@ -1,19 +1,26 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'optparse'
3
4
  require 'rubygems'
4
5
  require 'nats/client'
5
6
 
6
7
  def usage
7
- puts "Usage: nats-pub <subject> <msg>"; exit
8
+ puts "Usage: nats-pub <subject> <msg> [-s server]"; exit
8
9
  end
9
10
 
10
- subject, msg = ARGV
11
+ args = ARGV.dup
12
+ opts_parser = OptionParser.new do |opts|
13
+ opts.on('-s SERVER') { |server| $nats_server = server }
14
+ end
15
+ args = opts_parser.parse!(args)
16
+
17
+ subject, msg = args
11
18
  usage unless subject
12
19
  msg ||= 'Hello World'
13
20
 
14
21
  NATS.on_error { |err| puts "Server Error: #{err}"; exit! }
15
22
 
16
- NATS.start do
23
+ NATS.start(:uri => $nats_server, :autostart => true) do
17
24
  NATS.publish(subject, msg) { NATS.stop }
18
25
  end
19
26
 
@@ -1,21 +1,40 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'optparse'
3
4
  require 'rubygems'
4
5
  require 'nats/client'
5
6
 
6
- trap("TERM") { NATS.stop }
7
- trap("INT") { NATS.stop }
7
+ ['TERM', 'INT'].each { |s| trap(s) { puts; exit! } }
8
8
 
9
9
  def usage
10
- puts "Usage: nats-queue <subject> <queue name>"; exit
10
+ puts "Usage: nats-queue <subject> <queue name> [-s server] [-t]"; exit
11
11
  end
12
12
 
13
- subject, queue_group = ARGV
13
+ args = ARGV.dup
14
+ opts_parser = OptionParser.new do |opts|
15
+ opts.on('-s SERVER') { |server| $nats_server = server }
16
+ opts.on('-t') { $show_time = true }
17
+
18
+ end
19
+ args = opts_parser.parse!(args)
20
+
21
+ subject, queue_group = args
14
22
  usage unless subject and queue_group
15
23
 
24
+ def time_prefix
25
+ "[#{Time.now}] " if $show_time
26
+ end
27
+
28
+ def header
29
+ $i=0 unless $i
30
+ "#{time_prefix}[\##{$i+=1}]"
31
+ end
32
+
16
33
  NATS.on_error { |err| puts "Server Error: #{err}"; exit! }
17
34
 
18
- NATS.start do
35
+ NATS.start(:uri => $nats_server, :autostart => true) do
19
36
  puts "Listening on [#{subject}], queue group [#{queue_group}]"
20
- NATS.subscribe(subject, queue_group) { |msg| puts "Received '#{msg}'" }
37
+ NATS.subscribe(subject, :queue => queue_group) { |msg, _, sub|
38
+ puts "#{header} Received on [#{sub}] : '#{msg}'"
39
+ }
21
40
  end
@@ -1,22 +1,38 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'optparse'
3
4
  require 'rubygems'
4
5
  require 'nats/client'
5
6
 
6
- trap("TERM") { NATS.stop }
7
- trap("INT") { NATS.stop }
7
+ ['TERM', 'INT'].each { |s| trap(s) { puts; exit! } }
8
8
 
9
9
  def usage
10
- puts "Usage: nats-sub <subject>"; exit
10
+ puts "Usage: nats-sub <subject> [-s server] [-t]"; exit
11
11
  end
12
12
 
13
- subject = ARGV.shift
13
+ args = ARGV.dup
14
+ opts_parser = OptionParser.new do |opts|
15
+ opts.on('-s SERVER') { |server| $nats_server = server }
16
+ opts.on('-t') { $show_time = true }
17
+
18
+ end
19
+ args = opts_parser.parse!(args)
20
+
21
+ subject = args.shift
14
22
  usage unless subject
15
- i = 0
23
+
24
+ def time_prefix
25
+ "[#{Time.now}] " if $show_time
26
+ end
27
+
28
+ def header
29
+ $i=0 unless $i
30
+ "#{time_prefix}[\##{$i+=1}]"
31
+ end
16
32
 
17
33
  NATS.on_error { |err| puts "Server Error: #{err}"; exit! }
18
34
 
19
- NATS.start do
35
+ NATS.start(:uri => $nats_server, :autostart => true) do
20
36
  puts "Listening on [#{subject}]"
21
- NATS.subscribe(subject) { |msg, _, sub| puts "\##{i+=1}: Received on [#{sub}] : '#{msg}'" }
37
+ NATS.subscribe(subject) { |msg, _, sub| puts "#{header} Received on [#{sub}] : '#{msg}'" }
22
38
  end
@@ -8,7 +8,7 @@ require "#{ep}/ext/json"
8
8
 
9
9
  module NATS
10
10
 
11
- VERSION = "0.4.2".freeze
11
+ VERSION = "0.4.8".freeze
12
12
 
13
13
  DEFAULT_PORT = 4222
14
14
  DEFAULT_URI = "nats://localhost:#{DEFAULT_PORT}".freeze
@@ -16,16 +16,13 @@ module NATS
16
16
  MAX_RECONNECT_ATTEMPTS = 10
17
17
  RECONNECT_TIME_WAIT = 2
18
18
 
19
- AUTOSTART_PID_FILE = '/tmp/nats-server.pid'
20
- AUTOSTART_LOG_FILE = '/tmp/nats-server.log'
21
-
22
19
  # Protocol
23
20
  # @private
24
- MSG = /\AMSG\s+([^\s\r\n]+)\s+([^\s\r\n]+)\s+(([^\s\r\n]+)[^\S\r\n]+)?(\d+)\r\n/i #:nodoc:
21
+ MSG = /\AMSG\s+([^\s]+)\s+([^\s]+)\s+(([^\s]+)[^\S\r\n]+)?(\d+)\r\n/i #:nodoc:
25
22
  OK = /\A\+OK\s*\r\n/i #:nodoc:
26
23
  ERR = /\A-ERR\s+('.+')?\r\n/i #:nodoc:
27
- PING = /\APING\r\n/i #:nodoc:
28
- PONG = /\APONG\r\n/i #:nodoc:
24
+ PING = /\APING\s*\r\n/i #:nodoc:
25
+ PONG = /\APONG\s*\r\n/i #:nodoc:
29
26
  INFO = /\AINFO\s+([^\r\n]+)\r\n/i #:nodoc:
30
27
  UNKNOWN = /\A(.*)\r\n/ #:nodoc:
31
28
 
@@ -46,6 +43,10 @@ module NATS
46
43
  AWAITING_CONTROL_LINE = 1 #:nodoc:
47
44
  AWAITING_MSG_PAYLOAD = 2 #:nodoc:
48
45
 
46
+ # Autostart properties
47
+ AUTOSTART_PID_FILE = '/tmp/nats-server.pid'
48
+ AUTOSTART_LOG_FILE = '/tmp/nats-server.log'
49
+
49
50
  # Duplicate autostart protection
50
51
  @@tried_autostart = {}
51
52
 
@@ -59,12 +60,12 @@ module NATS
59
60
  alias :reactor_was_running? :reactor_was_running
60
61
 
61
62
  # Create and return a connection to the server with the given options.
62
- # The server will be autostarted if needed if the <b>uri</b> is determined to be local.
63
+ # The server will be autostarted if requested and the <b>uri</b> is determined to be local.
63
64
  # The optional block will be called when the connection has been completed.
64
65
  #
65
66
  # @param [Hash] opts
66
67
  # @option opts [String] :uri The URI to connect to, example nats://localhost:4222
67
- # @option opts [Boolean] :autostart Boolean that can be used to suppress autostart functionality.
68
+ # @option opts [Boolean] :autostart Boolean that can be used to engage server autostart functionality.
68
69
  # @option opts [Boolean] :reconnect Boolean that can be used to suppress reconnect functionality.
69
70
  # @option opts [Boolean] :debug Boolean that can be used to output additional debug information.
70
71
  # @option opts [Boolean] :verbose Boolean that is sent to server for setting verbose protocol mode.
@@ -82,11 +83,10 @@ module NATS
82
83
  opts[:verbose] = ENV['NATS_VERBOSE'] unless ENV['NATS_VERBOSE'].nil?
83
84
  opts[:pedantic] = ENV['NATS_PEDANTIC'] unless ENV['NATS_PEDANTIC'].nil?
84
85
  opts[:debug] = ENV['NATS_DEBUG'] if !ENV['NATS_DEBUG'].nil?
85
- opts[:autostart] = (ENV['NATS_AUTO'] || true) if opts[:autostart].nil?
86
-
87
86
  @uri = opts[:uri] = URI.parse(opts[:uri])
88
87
  @err_cb = proc { raise Error, "Could not connect to server on #{@uri}."} unless err_cb
89
- check_autostart(@uri) if opts[:autostart]
88
+ check_autostart(@uri) if opts[:autostart] == true
89
+
90
90
  client = EM.connect(@uri.host, @uri.port, self, opts)
91
91
  client.on_connect(&blk) if blk
92
92
  return client
@@ -207,7 +207,7 @@ module NATS
207
207
  log_arg = "-l #{AUTOSTART_LOG_FILE}"
208
208
  pid_arg = "-P #{AUTOSTART_PID_FILE}"
209
209
  # daemon mode to release client
210
- system("nats-server #{port_arg} #{user_arg} #{pass_arg} #{log_arg} #{pid_arg} -d 2> /dev/null")
210
+ `nats-server #{port_arg} #{user_arg} #{pass_arg} #{log_arg} #{pid_arg} -d 2> /dev/null`
211
211
  $? == 0
212
212
  end
213
213
 
@@ -26,6 +26,6 @@ EM.run {
26
26
  rescue => e
27
27
  log "Could not start server on port #{NATSD::Server.port}"
28
28
  log_error
29
- exit
29
+ exit(1)
30
30
  end
31
31
  }
@@ -1,7 +1,7 @@
1
1
 
2
2
  module NATSD #:nodoc:
3
3
 
4
- VERSION = '0.4.2'
4
+ VERSION = '0.4.8'
5
5
  APP_NAME = 'nats-server'
6
6
 
7
7
  DEFAULT_PORT = 4222
@@ -12,11 +12,12 @@ module NATSD #:nodoc:
12
12
  AWAITING_MSG_PAYLOAD = 2
13
13
 
14
14
  # Ops - See protocol.txt for more info
15
- INFO = /\AINFO\r\n/i
16
- PUB_OP = /\APUB\s+([^\s\r\n]+)\s+(([^\s\r\n]+)[^\S\r\n]+)?(\d+)\r\n/i
17
- SUB_OP = /\ASUB\s+([^\s\r\n]+)\s+(([^\s\r\n]+)[^\S\r\n]+)?([^\s\r\n]+)\r\n/i
18
- UNSUB_OP = /\AUNSUB\s+([^\s\r\n]+)\s*(\s+(\d+))?\r\n/i
19
- PING = /\APING\r\n/i
15
+ INFO = /\AINFO\s*\r\n/i
16
+ PUB_OP = /\APUB\s+([^\s]+)\s+(([^\s]+)[^\S\r\n]+)?(\d+)\r\n/i
17
+ SUB_OP = /\ASUB\s+([^\s]+)\s+(([^\s]+)[^\S\r\n]+)?([^\s]+)\r\n/i
18
+ UNSUB_OP = /\AUNSUB\s+([^\s]+)\s*(\s+(\d+))?\r\n/i
19
+ PING = /\APING\s*\r\n/i
20
+ PONG = /\APONG\s*\r\n/i
20
21
  CONNECT = /\ACONNECT\s+([^\r\n]+)\r\n/i
21
22
  UNKNOWN = /\A(.*)\r\n/
22
23
 
@@ -19,8 +19,7 @@ module NATSD
19
19
  opts.on("-d", "--daemonize", "Run daemonized in the background") { @options[:daemonize] = true }
20
20
  opts.on("-P", "--pid FILE", "File to store PID") { |file| @options[:pid_file] = file }
21
21
 
22
- opts.on("-C", "--config FILE", "Configuration File " +
23
- "(default: #{@options[:config_file]})") { |file| @options[:config_file] = file }
22
+ opts.on("-c", "--config FILE", "Configuration File") { |file| @options[:config_file] = file }
24
23
 
25
24
  opts.separator ""
26
25
  opts.separator "Logging options:"
@@ -53,18 +52,22 @@ module NATSD
53
52
  def read_config_file
54
53
  return unless config_file = @options[:config_file]
55
54
  config = File.open(config_file) { |f| YAML.load(f) }
55
+
56
56
  # Command lines args, parsed first, will override these.
57
57
  @options[:port] = config['port'] if @options[:port].nil?
58
58
  @options[:addr] = config['net'] if @options[:addr].nil?
59
+
59
60
  if auth = config['authorization']
60
61
  @options[:user] = auth['user'] if @options[:user].nil?
61
62
  @options[:pass] = auth['password'] if @options[:pass].nil?
63
+ @options[:pass] = auth['pass'] if @options[:pass].nil?
62
64
  @options[:token] = auth['token'] if @options[:token].nil?
63
65
  @options[:auth_timeout] = auth['timeout'] if @options[:auth_timeout].nil?
64
66
  end
67
+
65
68
  @options[:pid_file] = config['pid_file'] if @options[:pid_file].nil?
66
69
  @options[:log_file] = config['log_file'] if @options[:log_file].nil?
67
- @options[:logtime] = config['logtime'] if @options[:logtime].nil?
70
+ @options[:log_time] = config['logtime'] if @options[:log_time].nil?
68
71
  @options[:debug] = config['debug'] if @options[:debug].nil?
69
72
  @options[:trace] = config['trace'] if @options[:trace].nil?
70
73
 
@@ -123,6 +126,5 @@ module NATSD
123
126
  end
124
127
 
125
128
  end
126
-
127
129
  end
128
130
  end
@@ -13,7 +13,7 @@ module NATSD #:nodoc: all
13
13
  alias debug_flag? :debug_flag
14
14
  alias trace_flag? :trace_flag
15
15
 
16
- def version; "nats server version #{NATSD::VERSION}" end
16
+ def version; "nats-server version #{NATSD::VERSION}" end
17
17
 
18
18
  def host; @options[:addr] end
19
19
  def port; @options[:port] end
@@ -24,8 +24,11 @@ module NATSD #:nodoc: all
24
24
 
25
25
  # Allow command line to override config file, so do them first.
26
26
  parser.parse!(argv)
27
- read_config_file
27
+ read_config_file if @options[:config_file]
28
28
  finalize_options
29
+ rescue OptionParser::InvalidOption => e
30
+ log_error "Error parsing options: #{e}"
31
+ exit(1)
29
32
  end
30
33
 
31
34
  def setup(argv)
@@ -58,7 +61,7 @@ module NATSD #:nodoc: all
58
61
  EM.epoll unless @options[:noepoll]
59
62
  EM.kqueue unless @options[:nokqueue]
60
63
 
61
- # Write pid file if need be.
64
+ # Write pid file if requested.
62
65
  File.open(@options[:pid_file], 'w') { |f| f.puts "#{Process.pid}" } if @options[:pid_file]
63
66
  end
64
67
 
@@ -170,90 +173,91 @@ module NATSD #:nodoc: all
170
173
  # while (@buf && !@buf.empty? && !@closing)
171
174
  while (@buf && !@closing)
172
175
  case @parse_state
173
-
174
- when AWAITING_CONTROL_LINE
175
- case @buf
176
- when PUB_OP
177
- ctrace('PUB OP', strip_op($&)) if NATSD::Server.trace_flag?
178
- return connect_auth_timeout if @auth_pending
179
- @buf = $'
180
- @parse_state = AWAITING_MSG_PAYLOAD
181
- @msg_sub, @msg_reply, @msg_size = $1, $3, $4.to_i
182
- if (@msg_size > NATSD::Server.max_payload)
183
- debug "Message payload size exceeded (#{@msg_size}/#{NATSD::Server.max_payload}), closing connection"
184
- error_close PAYLOAD_TOO_BIG
185
- end
186
- send_data(INVALID_SUBJECT) if (@pedantic && !(@msg_sub =~ SUB_NO_WC))
187
- when SUB_OP
188
- ctrace('SUB OP', strip_op($&)) if NATSD::Server.trace_flag?
189
- return connect_auth_timeout if @auth_pending
190
- @buf = $'
191
- sub, qgroup, sid = $1, $3, $4
192
- return send_data(INVALID_SUBJECT) if !($1 =~ SUB)
193
- return send_data(INVALID_SID_TAKEN) if @subscriptions[sid]
194
- sub = Subscriber.new(self, sub, sid, qgroup, 0)
195
- @subscriptions[sid] = sub
196
- Server.subscribe(sub)
197
- send_data(OK) if @verbose
198
- when UNSUB_OP
199
- ctrace('UNSUB OP', strip_op($&)) if NATSD::Server.trace_flag?
200
- return connect_auth_timeout if @auth_pending
201
- @buf = $'
202
- sid, sub = $1, @subscriptions[$1]
203
- return send_data(INVALID_SID_NOEXIST) unless sub
204
- # If we have set max_responses, we will unsubscribe once we have received the appropriate
205
- # amount of responses
206
- sub.max_responses = ($2 && $3) ? $3.to_i : nil
207
- delete_subscriber(sub) unless (sub.max_responses && (sub.num_responses < sub.max_responses))
208
- send_data(OK) if @verbose
209
- when PING
210
- ctrace('PING OP', strip_op($&)) if NATSD::Server.trace_flag?
211
- @buf = $'
212
- send_data(PONG_RESPONSE)
213
- when CONNECT
214
- ctrace('CONNECT OP', strip_op($&)) if NATSD::Server.trace_flag?
215
- @buf = $'
216
- begin
217
- config = JSON.parse($1, :symbolize_keys => true, :symbolize_names => true)
218
- process_connect_config(config)
219
- rescue => e
220
- send_data(INVALID_CONFIG)
221
- log_error
222
- end
223
- when INFO
224
- ctrace('INFO OP', strip_op($&)) if NATSD::Server.trace_flag?
225
- return connect_auth_timeout if @auth_pending
226
- @buf = $'
227
- send_info
228
- when UNKNOWN
229
- ctrace('Unknown Op', strip_op($&)) if NATSD::Server.trace_flag?
230
- return connect_auth_timeout if @auth_pending
231
- @buf = $'
232
- send_data(UNKNOWN_OP)
233
- else
234
- # If we are here we do not have a complete line yet that we understand.
235
- # If too big, cut the connection off.
236
- if @buf.bytesize > NATSD::Server.max_control_line
237
- debug "Control line size exceeded (#{@buf.bytesize}/#{NATSD::Server.max_control_line}), closing connection.."
238
- error_close PROTOCOL_OP_TOO_BIG
239
- end
240
- return
176
+ when AWAITING_CONTROL_LINE
177
+ case @buf
178
+ when PUB_OP
179
+ ctrace('PUB OP', strip_op($&)) if NATSD::Server.trace_flag?
180
+ return connect_auth_timeout if @auth_pending
181
+ @buf = $'
182
+ @parse_state = AWAITING_MSG_PAYLOAD
183
+ @msg_sub, @msg_reply, @msg_size = $1, $3, $4.to_i
184
+ if (@msg_size > NATSD::Server.max_payload)
185
+ debug "Message payload size exceeded (#{@msg_size}/#{NATSD::Server.max_payload}), closing connection"
186
+ error_close PAYLOAD_TOO_BIG
241
187
  end
242
- @buf = nil if (@buf && @buf.empty?)
243
-
244
- when AWAITING_MSG_PAYLOAD
245
- return unless (@buf.bytesize >= (@msg_size + CR_LF_SIZE))
246
- msg = @buf.slice(0, @msg_size)
247
- ctrace('Processing msg', @msg_sub, @msg_reply, msg) if NATSD::Server.trace_flag?
188
+ send_data(INVALID_SUBJECT) if (@pedantic && !(@msg_sub =~ SUB_NO_WC))
189
+ when SUB_OP
190
+ ctrace('SUB OP', strip_op($&)) if NATSD::Server.trace_flag?
191
+ return connect_auth_timeout if @auth_pending
192
+ @buf = $'
193
+ sub, qgroup, sid = $1, $3, $4
194
+ return send_data(INVALID_SUBJECT) if !($1 =~ SUB)
195
+ return send_data(INVALID_SID_TAKEN) if @subscriptions[sid]
196
+ sub = Subscriber.new(self, sub, sid, qgroup, 0)
197
+ @subscriptions[sid] = sub
198
+ Server.subscribe(sub)
248
199
  send_data(OK) if @verbose
249
- Server.route_to_subscribers(@msg_sub, @msg_reply, msg)
250
- @buf = @buf.slice((@msg_size + CR_LF_SIZE), @buf.bytesize)
251
- @msg_sub = @msg_size = @reply = nil
252
- @parse_state = AWAITING_CONTROL_LINE
253
- @buf = nil if (@buf && @buf.empty?)
200
+ when UNSUB_OP
201
+ ctrace('UNSUB OP', strip_op($&)) if NATSD::Server.trace_flag?
202
+ return connect_auth_timeout if @auth_pending
203
+ @buf = $'
204
+ sid, sub = $1, @subscriptions[$1]
205
+ if sub
206
+ # If we have set max_responses, we will unsubscribe once we have received
207
+ # the appropriate amount of responses.
208
+ sub.max_responses = ($2 && $3) ? $3.to_i : nil
209
+ delete_subscriber(sub) unless (sub.max_responses && (sub.num_responses < sub.max_responses))
210
+ send_data(OK) if @verbose
211
+ else
212
+ send_data(INVALID_SID_NOEXIST) if @pedantic
213
+ end
214
+ when PING
215
+ ctrace('PING OP', strip_op($&)) if NATSD::Server.trace_flag?
216
+ @buf = $'
217
+ send_data(PONG_RESPONSE)
218
+ when CONNECT
219
+ ctrace('CONNECT OP', strip_op($&)) if NATSD::Server.trace_flag?
220
+ @buf = $'
221
+ begin
222
+ config = JSON.parse($1)
223
+ process_connect_config(config)
224
+ rescue => e
225
+ send_data(INVALID_CONFIG)
226
+ log_error
227
+ end
228
+ when INFO
229
+ ctrace('INFO OP', strip_op($&)) if NATSD::Server.trace_flag?
230
+ return connect_auth_timeout if @auth_pending
231
+ @buf = $'
232
+ send_info
233
+ when UNKNOWN
234
+ ctrace('Unknown Op', strip_op($&)) if NATSD::Server.trace_flag?
235
+ return connect_auth_timeout if @auth_pending
236
+ @buf = $'
237
+ send_data(UNKNOWN_OP)
238
+ else
239
+ # If we are here we do not have a complete line yet that we understand.
240
+ # If too big, cut the connection off.
241
+ if @buf.bytesize > NATSD::Server.max_control_line
242
+ debug "Control line size exceeded (#{@buf.bytesize}/#{NATSD::Server.max_control_line}), closing connection.."
243
+ error_close PROTOCOL_OP_TOO_BIG
244
+ end
245
+ return
254
246
  end
247
+ @buf = nil if (@buf && @buf.empty?)
248
+
249
+ when AWAITING_MSG_PAYLOAD
250
+ return unless (@buf.bytesize >= (@msg_size + CR_LF_SIZE))
251
+ msg = @buf.slice(0, @msg_size)
252
+ ctrace('Processing msg', @msg_sub, @msg_reply, msg) if NATSD::Server.trace_flag?
253
+ send_data(OK) if @verbose
254
+ Server.route_to_subscribers(@msg_sub, @msg_reply, msg)
255
+ @buf = @buf.slice((@msg_size + CR_LF_SIZE), @buf.bytesize)
256
+ @msg_sub = @msg_size = @reply = nil
257
+ @parse_state = AWAITING_CONTROL_LINE
258
+ @buf = nil if (@buf && @buf.empty?)
259
+ end
255
260
  end
256
-
257
261
  end
258
262
 
259
263
  def send_info
@@ -261,12 +265,12 @@ module NATSD #:nodoc: all
261
265
  end
262
266
 
263
267
  def process_connect_config(config)
264
- @verbose = config[:verbose] unless config[:verbose].nil?
265
- @pedantic = config[:pedantic] unless config[:pedantic].nil?
268
+ @verbose = config['verbose'] unless config['verbose'].nil?
269
+ @pedantic = config['pedantic'] unless config['pedantic'].nil?
266
270
  return send_data(OK) unless Server.auth_required?
267
271
 
268
272
  EM.cancel_timer(@auth_pending)
269
- if Server.auth_ok?(config[:user], config[:pass])
273
+ if Server.auth_ok?(config['user'], config['pass'])
270
274
  send_data(OK) if @verbose
271
275
  @auth_pending = nil
272
276
  else
@@ -11,11 +11,11 @@ def log(*args) #:nodoc:
11
11
  end
12
12
 
13
13
  def debug(*args) #:nodoc:
14
- log *args if NATSD::Server.debug_flag?
14
+ log(*args) if NATSD::Server.debug_flag?
15
15
  end
16
16
 
17
17
  def trace(*args) #:nodoc:
18
- log *args if NATSD::Server.trace_flag?
18
+ log(*args) if NATSD::Server.trace_flag?
19
19
  end
20
20
 
21
21
  def log_error(e=$!) #:nodoc:
@@ -3,12 +3,11 @@
3
3
  lib = File.expand_path('../lib/', __FILE__)
4
4
  $:.unshift lib unless $:.include?(lib)
5
5
 
6
- require 'nats/server/const.rb'
6
+ require 'nats/server/const'
7
7
 
8
8
  spec = Gem::Specification.new do |s|
9
9
  s.name = 'nats'
10
10
  s.version = NATSD::VERSION
11
- s.date = '2011-02-09'
12
11
  s.summary = 'A lightweight publish-subscribe messaging system.'
13
12
  s.homepage = 'http://github.com/derekcollison/nats'
14
13
  s.description = 'A lightweight publish-subscribe messaging system.'
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: nats
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.2
5
+ version: 0.4.8
6
6
  platform: ruby
7
7
  authors:
8
8
  - Derek Collison
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-02-09 00:00:00 -06:00
13
+ date: 2011-04-02 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  requirements: []
103
103
 
104
104
  rubyforge_project:
105
- rubygems_version: 1.5.2
105
+ rubygems_version: 1.6.2
106
106
  signing_key:
107
107
  specification_version: 3
108
108
  summary: A lightweight publish-subscribe messaging system.