Method: Etcd::Client#initialize

Defined in:
lib/etcd/client.rb

#initialize(opts = {}) {|@config| ... } ⇒ Client

Creates an Etcd::Client object. It accepts a hash opts as argument

rubocop:disable CyclomaticComplexity

Parameters:

  • (defaults to: {})

    The options for new Etcd::Client object

Yields:



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/etcd/client.rb', line 52

def initialize(opts = {})
  @host = opts[:host] || '127.0.0.1'
  @port = opts[:port] || 4001
  @config = Config.new
  @config.read_timeout = opts[:read_timeout] || 60
  @config.use_ssl = opts[:use_ssl] || false
  @config.verify_mode = opts.key?(:verify_mode) ? opts[:verify_mode] : OpenSSL::SSL::VERIFY_PEER
  @config.user_name = opts[:user_name] || nil
  @config.password = opts[:password] || nil
  @config.ca_file = opts.key?(:ca_file) ? opts[:ca_file] : nil
  # Provide a OpenSSL X509 cert here and not the path. See README
  @config.ssl_cert = opts.key?(:ssl_cert) ? opts[:ssl_cert] : nil
  # Provide the key (content) and not just the filename here.
  @config.ssl_key = opts.key?(:ssl_key) ? opts[:ssl_key] : nil
  yield @config if block_given?
end