Sha256: 23c6c5af8bb767152599438636961c8116f6f6ad1fd2fdda85badb5eeb26a221
Contents?: true
Size: 1.17 KB
Versions: 3
Compression:
Stored size: 1.17 KB
Contents
module Aggro module Handler # Private: Handler for incoming command requests. class Command < Struct.new(:message, :server) def call commandee_local? ? handle_local : handle_foreign end private def channel Aggro.channels[commandee_id] end def command @command ||= message.to_command end def commandee_id message.commandee_id end def command_known? !command.nil? end def commandee_local? comandee_locator.local? end def comandee_locator @comandee_locator ||= Locator.new(commandee_id) end def handle_foreign comandee_locator.primary_node.client.post message end def handle_known if channel.handles_command?(command) channel.forward_command command Message::OK.new else Message::UnhandledOperation.new end rescue NoMethodError Message::InvalidTarget.new end def handle_local command_known? ? handle_known : handle_unknown end def handle_unknown Message::UnknownOperation.new end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
aggro-0.0.4 | lib/aggro/handler/command.rb |
aggro-0.0.3 | lib/aggro/handler/command.rb |
aggro-0.0.2 | lib/aggro/handler/command.rb |