Class: COMAP::App

Inherits:
Object
  • Object
show all
Defined in:
lib/comap/app.rb

Overview

Rack App

Instance Method Summary collapse

Constructor Details

#initialize(docker_host: 'http://127.0.0.1', docker_port: '2375', docker_ssl: '', metrics_path: '', network: '', services: []) ⇒ App

rubocop:disable Metrics/ParameterLists

Raises:

  • (ArgumentError)


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/comap/app.rb', line 26

def initialize(
  docker_host: 'http://127.0.0.1',
  docker_port: '2375',
  docker_ssl: '',
  metrics_path: '',
  network: '',
  services: []
)
  raise ArgumentError, 'No services given' if services.empty?
  raise ArgumentError, 'No network given' if network.nil?

  ssl_hash = parse_ssl(docker_ssl)
  @client = DockerClient.new(docker_host, docker_port, ssl_hash)
  @network = network
  @services = services
  @metrics_path = metrics_path
  error_msg = 'Could not retrieve Docker API version from '\
    "#{docker_host}:#{docker_port} ssl:#{docker_ssl}"
  raise StandardError, error_msg if @client.call('version').nil?
end

Instance Method Details

#call(_env) ⇒ Object

rubocop:enable Metrics/ParameterLists



48
49
50
# File 'lib/comap/app.rb', line 48

def call(_env)
  ['200', { 'Content-Type' => 'text/plain' }, [body]]
end