Sha256: 20101b39fd3fe2edd66bfd72d0de298afe2d1184ab9088d7df7b8382741d16e8

Contents?: true

Size: 600 Bytes

Versions: 3

Compression:

Stored size: 600 Bytes

Contents

module Aggro
  module Handler
    # Private: Handler for incoming command requests.
    class GetEvents < Struct.new(:message, :server)
      def call
        local? ? handle_local : handle_foreign
      end

      private

      def handle_local
        events = Aggro.store.read([message.id]).first.events

        Message::Events.new(message.id, events.to_a)
      end

      def handle_foreign
        Message::Ask.new locator.primary_node.id
      end

      def local?
        locator.local?
      end

      def locator
        @locator ||= Locator.new(message.id)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
aggro-0.0.4 lib/aggro/handler/get_events.rb
aggro-0.0.3 lib/aggro/handler/get_events.rb
aggro-0.0.2 lib/aggro/handler/get_events.rb