class Etcdv3::Connection
Constants
- HANDLERS
- NAMESPACE_HANDLERS
Attributes
credentials[R]
endpoint[R]
handlers[R]
hostname[R]
namespace[R]
Public Class Methods
new(url, timeout, namespace, metadata={})
click to toggle source
# File lib/etcdv3/connection.rb, line 21 def initialize(url, timeout, namespace, metadata={}) @endpoint = URI(url) @hostname = "#{@endpoint.hostname}:#{@endpoint.port}" @namespace = namespace @credentials = resolve_credentials @timeout = timeout @handlers = handler_map(metadata) end
Public Instance Methods
call(stub, method, method_args=[])
click to toggle source
# File lib/etcdv3/connection.rb, line 30 def call(stub, method, method_args=[]) @handlers.fetch(stub).send(method, *method_args) end
refresh_metadata(metadata)
click to toggle source
# File lib/etcdv3/connection.rb, line 34 def refresh_metadata(metadata) @handlers = handler_map(metadata) end
Private Instance Methods
handler_map(metadata={})
click to toggle source
# File lib/etcdv3/connection.rb, line 40 def handler_map(metadata={}) handlers = Hash[ HANDLERS.map do |key, klass| [key, klass.new(@hostname, @credentials, @timeout, metadata)] end ] # Override any handlers that are namespace compatable. if @namespace NAMESPACE_HANDLERS.each do |key, klass| handlers[key] = klass.new(@hostname, @credentials, @timeout, @namespace, metadata) end end handlers end
resolve_credentials()
click to toggle source
# File lib/etcdv3/connection.rb, line 56 def resolve_credentials case @endpoint.scheme when 'http' :this_channel_is_insecure when 'https' # Use default certs for now. GRPC::Core::ChannelCredentials.new else raise "Unknown scheme: #{@endpoint.scheme}" end end