Module: Polyseerio::Agent::Executor
- Defined in:
- lib/agent/executor.rb
Overview
Agent executor functions.
Class Method Summary collapse
-
.setup(client, options = {}) ⇒ Object
Setsup a client’s agent.
-
.teardown(client, instance) ⇒ Object
Tearsdown a client’s agent.
Class Method Details
.setup(client, options = {}) ⇒ Object
Setsup a client’s agent.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/agent/executor.rb', line 13 def self.setup(client, = {}) Polyseerio.log 'debug', 'Setting up client agent.' = Polyseerio::Helper.defaults(, DEFAULT_CONFIG) Concurrent::Promise.new do if [:attach] name = Helper.resolve_name() # 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. = Helper. setup_handler = Helper.setup_with_handler( Polyseerio::Agent::Handler::MAP, client, ) # Gather setup operations. setups = .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) ⇒ Object
Tearsdown a client’s agent.
56 57 58 59 60 61 62 |
# 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 |