Method: NATS#initialize

Defined in:
lib/nats/client.rb

#initialize(options) ⇒ Object

[View source]

456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
# File 'lib/nats/client.rb', line 456

def initialize(options)
  @options = options
  process_uri_options

  @buf = nil
  @ssid, @subs = 1, {}
  @err_cb = NATS.err_cb
  @close_cb = NATS.close_cb
  @reconnect_cb = NATS.reconnect_cb
  @disconnect_cb = NATS.disconnect_cb
  @reconnect_timer, @needed = nil, nil
  @connected, @closing, @reconnecting, @conn_cb_called = false, false, false, false
  @msgs_received = @msgs_sent = @bytes_received = @bytes_sent = @pings = 0
  @pending_size = 0
  @server_info = { }

  # Mark whether we should be connecting securely, try best effort
  # in being compatible with present ssl support.
  @ssl = false
  @tls = nil
  @tls = options[:tls] if options[:tls]
  @ssl = options[:ssl] if options[:ssl] or @tls

  # New style request/response implementation.
  @resp_sub = nil
  @resp_map = nil
  @resp_sub_prefix = nil
  @nuid = NATS::NUID.new

  # Drain mode
  @draining = false
  @drained_subs = false

  # NKEYS
  @user_credentials = options[:user_credentials] if options[:user_credentials]
  @nkeys_seed = options[:nkeys_seed] if options[:nkeys_seed]
  @user_nkey_cb = nil
  @user_jwt_cb = nil
  @signature_cb = nil

  # NKEYS
  setup_nkeys_connect if @user_credentials or @nkeys_seed
end