Class: EventSourcing::Aggregate::Manager

Inherits:
Concurrent::Actor::RestartingContext
  • Object
show all
Defined in:
lib/event_sourcing/aggregate/manager.rb,
lib/event_sourcing/aggregate/manager/cache.rb,
lib/event_sourcing/aggregate/manager/reference.rb,
lib/event_sourcing/aggregate/manager/instance_of.rb

Defined Under Namespace

Classes: Cache, Reference

Constant Summary collapse

InstanceOf =
Value.new(:aggregate, :id)

Instance Method Summary collapse

Constructor Details

#initialize(event_bus) ⇒ Manager

Returns a new instance of Manager.



11
12
13
# File 'lib/event_sourcing/aggregate/manager.rb', line 11

def initialize(event_bus)
  @event_bus = event_bus
end

Instance Method Details

#default_reference_classObject



23
24
25
# File 'lib/event_sourcing/aggregate/manager.rb', line 23

def default_reference_class
  Reference
end

#on_message(message) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/event_sourcing/aggregate/manager.rb', line 15

def on_message(message)
  case message
  when Aggregate::Message
    cache.instance_of(message.aggregate, message.id).tell(message.message)
    #TODO Handle aggregate timeout and failure (remove from cache)
  end
end