Module: Cuboid::Rest::Server::InstanceHelpers

Includes:
Server::InstanceHelpers
Defined in:
lib/cuboid/rest/server/instance_helpers.rb

Overview

Sinatra-coupled supplement to ‘Cuboid::Server::InstanceHelpers` —the methods that read `env` or call `handle_error` (a Sinatra helper defined on `Rest::Server`). Everything that doesn’t need Sinatra stays on the shared module above.

Instance Method Summary collapse

Methods included from Server::InstanceHelpers

agent, #agent, #agents, connect_to_agent, #connect_to_agent, connect_to_instance, #connect_to_instance, #connect_to_scheduler, #exists?, instances, #instances, #scheduler, spawn, #unplug_agent, #update_from_scheduler

Instance Method Details

#instance_for(id, &block) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/cuboid/rest/server/instance_helpers.rb', line 21

def instance_for( id, &block )
    cleanup = proc { instances.delete( id ).close }

    handle_error cleanup do
        block.call instances[id]
    end
end

#spawn(owner_url: env['HTTP_HOST']) ⇒ Object

Forward the request host to the shared spawner so the Agent can log who asked for the instance.



17
18
19
# File 'lib/cuboid/rest/server/instance_helpers.rb', line 17

def spawn( owner_url: env['HTTP_HOST'] )
    super
end