Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefaultApplyStrategy for AggregateRoot fails when using protobuf #578

Closed
obahareth opened this issue May 1, 2019 · 4 comments · Fixed by #579
Closed

DefaultApplyStrategy for AggregateRoot fails when using protobuf #578

obahareth opened this issue May 1, 2019 · 4 comments · Fixed by #579
Labels

Comments

@obahareth
Copy link

obahareth commented May 1, 2019

When you use Protobuf for your events along with AggregateRoot, the AggregateRoot default apply strategy tries to call a handler called apply_proto because it isn't reading the event class (It's reading event.class instead of event.data.class in the case of protobuf). It seems like we need a different apply strategy for protobuf.

The examples below all work if you use the default events and YAML, but when switching to Protobuf they don't.

Sample output

AggregateRoot::MissingHandler (Missing handler method apply_proto on aggregate MyAggregate)

Sample aggregate

class MyAggregate
  include AggregateRoot

  def initialize
    @amount = 0
  end

  def add_amount(amount)
    @amount += amount
  end

  on BalanceAdded do |event|
    add_amount(event.data.fetch(:amount, 0))
  end


  private

  attr_reader :amount
end
@obahareth obahareth changed the title DefaultApplyStrategy fails when using protobuf DefaultApplyStrategy for AggregateRoot fails when using protobuf May 1, 2019
paneq added a commit that referenced this issue May 1, 2019
@paneq
Copy link
Member

paneq commented May 1, 2019

@obahareth Nice catch. This might fix it #579 , could you give it a try? It's just PoC.

@obahareth
Copy link
Author

#579 does fix it, thanks!

@mostlyobvious
Copy link
Member

Continued in #582

@mostlyobvious
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants