Class: Sequent::Core::AggregateSnapshotter

Inherits:
BaseCommandHandler show all
Defined in:
lib/sequent/core/aggregate_snapshotter.rb

Instance Method Summary collapse

Methods included from Helpers::MessageHandler

#dispatch_message, #handle_message, included

Methods included from Helpers::UuidHelper

new_uuid

Instance Method Details

#take_snapshot(aggregate_id) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/sequent/core/aggregate_snapshotter.rb', line 39

def take_snapshot(aggregate_id)
  aggregate = repository.load_aggregate(aggregate_id)
  Sequent.logger.info "Taking snapshot for aggregate #{aggregate}"
  aggregate.take_snapshot
rescue StandardError => e
  Sequent.logger.error("Failed to take snapshot for aggregate #{aggregate_id}: #{e}, #{e.inspect}")
  nil
end