Class: Smith::Commands::Kill

Inherits:
Smith::CommandBase show all
Includes:
Common
Defined in:
lib/smith/commands/agency/kill.rb

Instance Attribute Summary

Attributes inherited from Smith::CommandBase

#options, #target

Instance Method Summary collapse

Methods included from Common

#agent_group

Methods inherited from Smith::CommandBase

#banner, #format_help, #initialize, #parse_options

Methods included from Logger

included

Constructor Details

This class inherits a constructor from Smith::CommandBase

Instance Method Details

#executeObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/smith/commands/agency/kill.rb', line 10

def execute
  work = ->(acc, uuid, iter) do
    if agents.exist?(uuid)
      agents[uuid].kill
    else
      acc << uuid
    end

    iter.return(acc)
  end

  done = ->(errors) { responder.succeed(format_error_message(errors)) }

  EM::Iterator.new(agents_to_kill).inject([], work, done)
end