envato / event_sourcery

A library for building event sourced applications in Ruby
MIT License
84 stars 10 forks source link

Remove processes_events from Event Stream Processor #161

Closed twe4ked closed 6 years ago

twe4ked commented 7 years ago

This PR removes support for the older syntax of defining a generic process method on event processors and using processes_events to control what events should trigger the process method to be called.

I've removed this functionality in favour of using the process EventName do |event| DSL.

Previously you could set up an event stream processor with a process method defined and tell event sourcery what events to process using the processes_events method:

class MyProjector
  include EventSourcery::EventProcessing::EventStreamProcessor

  processes_events :item_added

  def process(event)
    # only ItemAdded events will be processed.
  end
end
class MyProjector
  include EventSourcery::EventProcessing::EventStreamProcessor

  processes_all_events

  def process(event)
    # all events will be processed.
  end
end

We're removing that functionality in favour of the newer DSL.

class MyProjector
  include EventSourcery::EventProcessing::EventStreamProcessor

  process ItemAdded do |event|
    # only ItemAdded events will be processed.
  end
end
class MyProjector
  include EventSourcery::EventProcessing::EventStreamProcessor

  process do |event|
    # all events will be processed.
  end
end
macosgrove commented 7 years ago

@twe4ked Would you provide some context for this change please? Why is it being done?

twe4ked commented 7 years ago

@macosgrove I've updated the description.

macosgrove commented 7 years ago

Thanks @twe4ked. Change LGTM. Should we increment the major version number when this is released, as it is a breaking change?

twe4ked commented 6 years ago

@macosgrove @stevehodgkiss @orien @salamagd @andrewgr I finally got around to fixing the merge conflicts on this PR. Can I please get another review before I merge? There is also a matching PR on event_sourcery-postgres: https://github.com/envato/event_sourcery-postgres/pull/22.

Thanks