Parent

Methods

Included Modules

Docker::Connection

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.

Attributes

options[R]
url[R]

Public Class Methods

new(url, opts) click to toggle source

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

Public Instance Methods

request(*args, &block) click to toggle source

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
to_s() click to toggle source
# File lib/docker/connection.rb, line 60
def to_s
  "Docker::Connection { :url => #{url}, :options => #{options} }"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.