class Aggro::Handler::Query
Private: Handler
for incoming query requests.
Public Instance Methods
call()
click to toggle source
# File lib/aggro/handler/query.rb, line 5 def call queryee_local? ? handle_local : handle_foreign end
Private Instance Methods
channel()
click to toggle source
# File lib/aggro/handler/query.rb, line 11 def channel Aggro.channels[queryable_id] end
comandee_locator()
click to toggle source
# File lib/aggro/handler/query.rb, line 31 def comandee_locator @comandee_locator ||= Locator.new(queryable_id) end
handle_foreign()
click to toggle source
# File lib/aggro/handler/query.rb, line 35 def handle_foreign comandee_locator.primary_node.client.post message end
handle_known()
click to toggle source
# File lib/aggro/handler/query.rb, line 39 def handle_known if channel if channel.handles_query?(query) handle_supported else Message::UnhandledOperation.new end else Message::InvalidTarget.new end end
handle_local()
click to toggle source
# File lib/aggro/handler/query.rb, line 51 def handle_local query_known? ? handle_known : handle_unknown end
handle_supported()
click to toggle source
# File lib/aggro/handler/query.rb, line 59 def handle_supported result = channel.run_query(query) result.wait(5) if result.fulfilled? Message::Result.new result.value else Message::Result.new Aggro::QueryError.new('Query timed out') end end
handle_unknown()
click to toggle source
# File lib/aggro/handler/query.rb, line 55 def handle_unknown Message::UnknownOperation.new end
query()
click to toggle source
# File lib/aggro/handler/query.rb, line 15 def query @query ||= message.to_query end
query_known?()
click to toggle source
# File lib/aggro/handler/query.rb, line 23 def query_known? !query.nil? end
queryable_id()
click to toggle source
# File lib/aggro/handler/query.rb, line 19 def queryable_id message.queryable_id end
queryee_local?()
click to toggle source
# File lib/aggro/handler/query.rb, line 27 def queryee_local? comandee_locator.local? end