Method: Gruf::Client#initialize

Defined in:
lib/gruf/client.rb

#initialize(service:, options: {}, client_options: {}) ⇒ Client

Initialize the client and setup the stub

Options Hash (options:):

  • :password (String)

    The password for basic authentication for the service.

  • :hostname (String)

    The hostname of the service. Defaults to linkerd.



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/gruf/client.rb', line 57

def initialize(service:, options: {}, client_options: {})
  @base_klass = service
  @service_klass = "#{base_klass}::Service".constantize
  @opts = options || {}
  @opts[:password] = @opts.fetch(:password, '').to_s
  @opts[:hostname] = @opts.fetch(:hostname, Gruf.default_client_host)
  @opts[:channel_credentials] = @opts.fetch(:channel_credentials, Gruf.default_channel_credentials)
  @error_factory = Gruf::Client::ErrorFactory.new
  client_options[:timeout] = parse_timeout(client_options[:timeout]) if client_options.key?(:timeout)
  client = "#{service}::Stub".constantize.new(@opts[:hostname], build_ssl_credentials, **client_options)
  super(client)
end