Class: Docker::API::Transport::Base Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/docker/api/transport/base.rb

Overview

This class is abstract.

Subclass and implement #connect.

The contract every transport honours: make a socket, say what Host header requests over it should carry, and describe yourself for logs.

Transports know how to dial, and nothing else. Keeping them this narrow is what makes the layer above testable -- Fake is a drop-in because there is so little to stand in for.

Direct Known Subclasses

Fake, NamedPipe, Tcp, Unix

Instance Method Summary collapse

Instance Method Details

#connectIO

Open a connection.

Returns:

  • (IO)

    a connected, readable and writable socket

Raises:



22
23
24
# File 'lib/docker/api/transport/base.rb', line 22

def connect
  raise NotImplementedError, "#{self.class} must implement #connect"
end

#host_headerString

The daemon does not route on Host, but HTTP/1.1 requires the header and some proxies in front of a daemon do care.

Returns:

  • (String)


30
31
32
# File 'lib/docker/api/transport/base.rb', line 30

def host_header
  "localhost"
end

#to_sString Also known as: inspect

Returns a description safe to put in a log line.

Returns:

  • (String)

    a description safe to put in a log line



35
36
37
# File 'lib/docker/api/transport/base.rb', line 35

def to_s
  "#<#{self.class.name}>"
end