Skip to content

Commit

Permalink
Retrying on unsuccessful aggregate updates
Browse files Browse the repository at this point in the history
This is a hotfix as the current solution crashes the system and it puts in inconsistent state. It happens because adding item to offer triggers 2 additional commands changing the same aggregate.

The coldfix is non-trivial and requires a bigger redesign of the Pricing total calculation.
  • Loading branch information
andrzejkrzywda committed Jul 12, 2023
1 parent 13d085e commit 36ce8cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ecommerce/pricing/.mutant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ matcher:
- Pricing*
ignore:
- Pricing::Configuration*
- Pricing::Test*
- Pricing::Test*
- Pricing::OnCalculateTotalValue#call
- Pricing::OnCalculateTotalValue#calculate_sub_amounts
6 changes: 6 additions & 0 deletions ecommerce/pricing/lib/pricing/services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,18 @@ def call(command)
@repository.with_aggregate(Order, command.aggregate_id) do |order|
order.calculate_total_value(PricingCatalog.new(@event_store), time_promotions_discount)
end
rescue WrongExpectedEventVersion
retry
end



def calculate_sub_amounts(command)
@repository.with_aggregate(Order, command.aggregate_id) do |order|
order.calculate_sub_amounts(PricingCatalog.new(@event_store), time_promotions_discount)
end
rescue WrongExpectedEventVersion
retry
end

private
Expand Down

0 comments on commit 36ce8cb

Please sign in to comment.