module Polyseerio::Agent::Executor
Agent
executor functions.
Public Class Methods
setup(client, options = {})
click to toggle source
Setsup a client's agent.
# File lib/agent/executor.rb, line 13 def self.setup(client, options = {}) Polyseerio.log 'debug', 'Setting up client agent.' options = Polyseerio::Helper.defaults(options, DEFAULT_CONFIG) Concurrent::Promise.new do if options[:attach] name = Helper.resolve_name(options) # Resolve the instance. # TODO: better handle failure to upsert. instance = Resource::Routine.upsert( client.Instance, name: name ).execute.value # Set the client's instance. client.instance = instance # Create a setup handler. handler_options = Helper.extract_handler_options options setup_handler = Helper.setup_with_handler( Polyseerio::Agent::Handler::MAP, client, handler_options ) # Gather setup operations. setups = handler_options.map { |key, _| setup_handler.call(key) } # Perform setups. Concurrent::Promise.zip(*setups).execute.value # Start monitoring. Polyseerio.log 'debug', 'Attaching instance to Polyseer.io' instance.attach.execute.value instance end end end
teardown(client, instance)
click to toggle source
Tearsdown a client's agent.
# File lib/agent/executor.rb, line 56 def self.teardown(client, instance) Concurrent::Promise.new do teardown_handler('event', client) instance.detach.excecute.value end end