class Percheron::Connection
Public Class Methods
load!(config)
click to toggle source
rubocop:disable Style/ClassVars
# File lib/percheron/connection.rb, line 9 def self.load!(config) @@config = config instance.setup! instance end
perform(klass, method, *args, &blk)
click to toggle source
rubocop:enable Style/ClassVars
# File lib/percheron/connection.rb, line 16 def self.perform(klass, method, *args, &blk) instance.perform(klass, method, *args, &blk) end
Public Instance Methods
perform(klass, method, *args) { |out| ... }
click to toggle source
# File lib/percheron/connection.rb, line 20 def perform(klass, method, *args) klass.public_send(method, *args) { |out| yield(out) if block_given? } rescue => e $logger.debug '%s.%s(%s) - %s' % [ klass, method, args, e.inspect ] raise end
setup!()
click to toggle source
# File lib/percheron/connection.rb, line 27 def setup! set_url! set_options! end
Private Instance Methods
base_docker_options()
click to toggle source
# File lib/percheron/connection.rb, line 51 def base_docker_options { connect_timeout: config.docker.connect_timeout || 5, read_timeout: config.docker.read_timeout || 300 } end
cert_path_for(file)
click to toggle source
# File lib/percheron/connection.rb, line 67 def cert_path_for(file) File.join(config.docker.cert_path, file) end
config()
click to toggle source
# File lib/percheron/connection.rb, line 34 def config @@config end
docker_options()
click to toggle source
# File lib/percheron/connection.rb, line 47 def docker_options base_docker_options.merge(extra_docker_opts) end
extra_docker_opts()
click to toggle source
# File lib/percheron/connection.rb, line 58 def extra_docker_opts return {} unless config.docker.cert_path { client_cert: cert_path_for('cert.pem'), client_key: cert_path_for('key.pem'), ssl_ca_file: cert_path_for('ca.pem') } end
set_options!()
click to toggle source
# File lib/percheron/connection.rb, line 42 def set_options! Excon.defaults[:ssl_verify_peer] = config.docker.ssl_verify_peer Docker.options = docker_options end
set_url!()
click to toggle source
# File lib/percheron/connection.rb, line 38 def set_url! Docker.url = config.docker.host end