Class: Vx::Worker::StartConnector

Inherits:
Struct
  • Object
show all
Includes:
Helper::Config, Helper::Logger
Defined in:
lib/vx/worker/middlewares/start_connector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper::Logger

#logger

Methods included from Helper::Config

#config

Instance Attribute Details

#appObject

Returns the value of attribute app

Returns:

  • (Object)

    the current value of app



8
9
10
# File 'lib/vx/worker/middlewares/start_connector.rb', line 8

def app
  @app
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/vx/worker/middlewares/start_connector.rb', line 13

def call(env)
  options = config.connector_options
  options.merge! logger: logger
  env.connector = ContainerConnector.lookup(config.run, options)
  env.connector.start do |spawner|
    env.job.add_to_output "using #{Socket.gethostname}##{spawner.id}\n"
    logger.tagged("#{spawner.id}") do
      begin
        env.spawner = spawner
        app.call env
      ensure
        env.spawner = spawner
      end
    end
  end
end