Sha256: aa9164f1da90f5814b562b9cee31882f7a0c4a195c81d5eea100588a1416ecce

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

module <%= project_class_name %>
  module Reactors
    class <%= reactor_class_name %>
      include EventSourcery::Postgres::Reactor

      processor_name :<%= reactor_name.underscore %>

      # emits_events ExampleEvent, AnotherEvent

      # table :reactor_<%= reactor_name.underscore %> do
      #   column :todo_id, :uuid, primary_key: true
      #   column :title,   :text
      # end

    <%- if event_names.empty? -%>
      # process TodoAdded do |event|
      #   table.insert(
      #     todo_id: event.aggregate_id,
      #     title:   event.body['title'],
      #   )
      # end

      # process TodoCompleted do |event|
      #   todo = table.where(todo_id: event.aggregate_id).first
      #
      #   emit_event(
      #     StakeholderNotifiedOfTodoCompletion.new(
      #       aggregate_id: event.aggregate_id,
      #       body:         { title: todo[:title] },
      #     )
      #   )
      # end
    <%- else -%>
      <% event_names.each do |event_name| %>
      process <%= event_name.underscore.camelize %> do |event|
        # Update scratch tables, emit events, ...
      end
      <%- end -%>
    <%- end -%>
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
event_sourcery_generators-0.2.0 lib/event_sourcery_generators/generators/templates/reactor/reactor.rb.tt