This class represents a Connection to a Docker server. The Connection is immutable in that once the url and options is set they cannot be changed.
Create a new Connection. This method takes a url (String) and options (Hash). These are passed to Excon, so any options valid for `Excon.new` can be passed here.
# File lib/docker/connection.rb, line 11 def initialize(url, opts) case when !url.is_a?(String) raise ArgumentError, "Expected a String, got: '#{url}'" when !opts.is_a?(Hash) raise ArgumentError, "Expected a Hash, got: '#{opts}'" else uri = URI.parse(url) if uri.scheme == "unix" @url, @options = 'unix:///', {:socket => uri.path}.merge(opts) else @url, @options = url, opts end end end
Send a request to the server with the `
# File lib/docker/connection.rb, line 35 def request(*args, &block) request = compile_request_params(*args, &block) if Docker.logger Docker.logger.debug( [request[:method], request[:path], request[:query], request[:body]] ) end resource.request(request).body rescue Excon::Errors::BadRequest => ex raise ClientError, ex.message rescue Excon::Errors::Unauthorized => ex raise UnauthorizedError, ex.message rescue Excon::Errors::NotFound => ex raise NotFoundError, ex.message rescue Excon::Errors::InternalServerError => ex raise ServerError, ex.message rescue Excon::Errors::Timeout => ex raise TimeoutError, ex.message end
Generated with the Darkfish Rdoc Generator 2.