module Yao::Client
Attributes
default_client[RW]
@return [Yao::Client::ClientSet]
Public Class Methods
client_generator()
click to toggle source
@return [Yao::Plugins::DefaultClientGenerator]
# File lib/yao/client.rb, line 94 def client_generator Plugins::Registry.instance[:client_generator][Yao.config.client_generator].new end
client_options()
click to toggle source
generate Hash options for Faraday.new @return [Hash]
# File lib/yao/client.rb, line 119 def client_options opt = {} if Yao.config.timeout opt.merge!({ request: { timeout: Yao.config.timeout }}) end # Client Certificate Authentication if (Yao.config.client_cert && Yao.config.client_key) || Yao.config.ca_cert h = {} if Yao.config.client_cert && Yao.config.client_key cert = OpenSSL::X509::Certificate.new(File.read(Yao.config.client_cert)) key = OpenSSL::PKey.read(File.read(Yao.config.client_key)) h[:client_cert] = cert h[:client_key] = key end h[:ca_file] = Yao.config.ca_cert if Yao.config.ca_cert opt.merge!(ssl: h) end opt end
gen_client(endpoint, token: nil)
click to toggle source
@param endpoint [String] @param token [String] @return [Faraday::Connection]
# File lib/yao/client.rb, line 101 def gen_client(endpoint, token: nil) Faraday.new( endpoint, client_options ) do |f| client_generator.call(f, token) end end
reset_client(new_endpoint=nil)
click to toggle source
@param new_endpoint [String]
# File lib/yao/client.rb, line 108 def reset_client(new_endpoint=nil) set = ClientSet.new endpoint = { "default" => {public_url: new_endpoint || Yao.config.endpoint} } set.register_endpoints(endpoint) self.default_client = set end