class EventStoreClient::GRPC::Connection
Attributes
cert[R]
Public Class Methods
new()
click to toggle source
# File lib/event_store_client/adapters/grpc/connection.rb, line 33 def initialize retries ||= 0 @cert = Net::HTTP.start( config.eventstore_url.host, config.eventstore_url.port, use_ssl: true, verify_mode: verify_ssl, &:peer_cert ) rescue SocketError sleep config.socket_error_retry_sleep retry if (retries += 1) <= config.socket_error_retry_count raise SocketErrorRetryFailed end
Public Instance Methods
call(stub_klass, options: {})
click to toggle source
Initializes the proper stub with the necessary credentials to create working gRPC connection - Refer to generated grpc files @return [Stub] Instance of a given `Stub` klass
# File lib/event_store_client/adapters/grpc/connection.rb, line 18 def call(stub_klass, options: {}) credentials = options[:credentials] || Base64.encode64("#{config.eventstore_user}:#{config.eventstore_password}") stub_klass.new( "#{config.eventstore_url.host}:#{config.eventstore_url.port}", channel_credentials, channel_args: { 'authorization' => "Basic #{credentials.delete("\n")}" } ) end
Private Instance Methods
channel_credentials()
click to toggle source
# File lib/event_store_client/adapters/grpc/connection.rb, line 48 def channel_credentials ::GRPC::Core::ChannelCredentials.new(cert.to_s) end
verify_ssl()
click to toggle source
# File lib/event_store_client/adapters/grpc/connection.rb, line 52 def verify_ssl config.verify_ssl || OpenSSL::SSL::VERIFY_NONE end