class Riak::Client::BeefcakeProtobuffsBackend::BeefcakeSocket

A factory class for making sockets, whether secure or not @api private

Public Class Methods

new(host, port, options = {}) click to toggle source
# File lib/riak/client/beefcake/socket.rb, line 16
def new(host, port, options = {})
  return start_tcp_socket(host, port, options) if options[:authentication].blank?
  return start_tls_socket(host, port, options)
end

Private Class Methods

start_tcp_socket(host, port, options = {}) click to toggle source
# File lib/riak/client/beefcake/socket.rb, line 22
def start_tcp_socket(host, port, options = {})
  sock = if options[:connect_timeout] && RUBY_VERSION >= '2.0.0'
           Socket.tcp(host, port, connect_timeout: options[:connect_timeout])
         else
           Socket.tcp(host, port)
         end
  sock.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, true)
  sock
end
start_tls_socket(host, port, options) click to toggle source
# File lib/riak/client/beefcake/socket.rb, line 32
def start_tls_socket(host, port, options)
  authentication = options[:authentication]
  raise Riak::UserConfigurationError.new if authentication[:username]

  tcp = start_tcp_socket(host, port, options)
  TlsInitiator.new(tcp, host, authentication).tls_socket
end