rails_event_store 0.30.0 → 2.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3d4e0009af4124fcd60998861a6a397048887b9e5b3ea57dcf5356b2fd3c2c0
4
- data.tar.gz: f62347ca2d8bf35e365647b09720c6410cb0096b1c512f11176c77f09cc7a808
3
+ metadata.gz: f547a33f75be9a69d32ffc99ea19b680fb35744d5c20b478effcba828439ac2e
4
+ data.tar.gz: d6103a7a68b1ee7230f254445be460983b160c8d6e7383c300e658261a6702e2
5
5
  SHA512:
6
- metadata.gz: 59fd5ddb62bf2fb5e4db8c28771a1888b63bb6b2bbf3e16b0fc703d50a6e2956e65218eb0d6eb5fd3df417b8d49dc0c04a8eb8296a8e686ce32ee1b3721cfce0
7
- data.tar.gz: 8b2720a1bd23f634d5ae5475cad76e39c2a5845f73e99b4059421818af5b2bf34f278186bf807fdb615b146581055e10ab950c6079364262564eb5d789c0cb55
6
+ metadata.gz: 772a73bc208254277062b9cde2d811c29414cea5a698b2abeb36dfe32892155cf634223f32707fbb344df24205c36d793f55e6e23091d0a693950db803cce2c3
7
+ data.tar.gz: a1b8e4dd54fba0594cdefec218561b7abcfd8ca16f58f78c3e746e2b70de59ebacf8da4e188c0c5ed9e845aaed6dd700d7acb5c3df4b2b7bd35b0eeac02555f0
data/README.md CHANGED
@@ -1,3 +1,7 @@
1
1
  # RailsEventStore
2
2
 
3
- Rails wrapper for Ruby Event Store with batteries included.
3
+ Rails wrapper for RubyEventStore with batteries included.
4
+
5
+ Ships with asynchronous after-commit event dispatch on top of ActiveJob, ActiveSupport::Notifications instrumentation enabled, request metadata enrichment and opinionated directory structure generator for bounded contexts.
6
+
7
+ Find out more at [https://railseventstore.org](https://railseventstore.org/)
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators"
4
+
5
+ module RailsEventStore
6
+ module Generators
7
+ class BoundedContextGenerator < Rails::Generators::NamedBase
8
+ source_root File.expand_path(File.join(File.dirname(__FILE__), "../templates"))
9
+ hook_for :test_framework
10
+
11
+ def create_bounded_context
12
+ create_file "#{bounded_context_name}/lib/#{bounded_context_name}/.keep"
13
+
14
+ template "module.rb", "#{bounded_context_name}/lib/#{bounded_context_name}.rb"
15
+
16
+ application { "config.paths.add '#{bounded_context_name}/lib', eager_load: true" }
17
+ end
18
+
19
+ private
20
+
21
+ def bounded_context_namespace
22
+ name.camelize
23
+ end
24
+
25
+ def bounded_context_name
26
+ name.underscore
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators"
4
+
5
+ module RailsEventStore
6
+ module Generators
7
+ class RspecGenerator < Rails::Generators::NamedBase
8
+ source_root File.expand_path(File.join(File.dirname(__FILE__), "../templates"))
9
+
10
+ def spec_helper
11
+ template "spec_helper.rb", "#{bounded_context_name}/spec/spec_helper.rb"
12
+ end
13
+
14
+ def bc_spec
15
+ template "bc_spec.rb", "#{bounded_context_name}/spec/#{bounded_context_name}_spec.rb"
16
+ end
17
+
18
+ def require_bc_spec
19
+ template "require_bc_spec.rb", "spec/#{bounded_context_name}_spec.rb"
20
+ end
21
+
22
+ private
23
+
24
+ def bounded_context_namespace
25
+ name.camelize
26
+ end
27
+
28
+ def bounded_context_name
29
+ name.underscore
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators"
4
+
5
+ module RailsEventStore
6
+ module Generators
7
+ class TestUnitGenerator < Rails::Generators::NamedBase
8
+ source_root File.expand_path(File.join(File.dirname(__FILE__), "../templates"))
9
+
10
+ def test_helper
11
+ template "test_helper.rb", "#{bounded_context_name}/test/test_helper.rb"
12
+ end
13
+
14
+ def require_bc_test
15
+ template "require_bc_test.rb", "test/#{bounded_context_name}_test.rb"
16
+ end
17
+
18
+ private
19
+
20
+ def bounded_context_name
21
+ name.underscore
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,4 @@
1
+ require_relative "spec_helper"
2
+
3
+ ::RSpec.describe <%= bounded_context_namespace %> do
4
+ end
@@ -0,0 +1,2 @@
1
+ module <%= bounded_context_namespace %>
2
+ end
@@ -0,0 +1,4 @@
1
+ require "rails_helper"
2
+
3
+ path = Rails.root.join("<%= bounded_context_name %>/spec")
4
+ Dir.glob("#{path}/**/*_spec.rb") { |file| require file }
@@ -0,0 +1,3 @@
1
+ require "test_helper"
2
+
3
+ Dir[Rails.root.join("<%= bounded_context_name %>/test/*_test.rb")].each { |file| require file }
@@ -0,0 +1,7 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+
3
+ $LOAD_PATH.push File.expand_path("../../../spec", __FILE__)
4
+ require File.expand_path("../../../config/environment", __FILE__)
5
+ require File.expand_path("../../../spec/rails_helper", __FILE__)
6
+
7
+ require_relative "../lib/<%= bounded_context_name %>"
@@ -0,0 +1 @@
1
+ require_relative "../lib/<%= bounded_context_name %>"
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_job"
4
+
5
+ module RailsEventStore
6
+ class ActiveJobScheduler
7
+ def initialize(serializer:)
8
+ @serializer = serializer
9
+ end
10
+
11
+ def call(klass, record)
12
+ klass.perform_later(record.serialize(serializer).to_h.transform_keys(&:to_s))
13
+ end
14
+
15
+ def verify(subscriber)
16
+ Class === subscriber && !!(subscriber < ActiveJob::Base)
17
+ end
18
+
19
+ private
20
+
21
+ attr_reader :serializer
22
+ end
23
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsEventStore
4
+ class AfterCommitAsyncDispatcher
5
+ def initialize(scheduler:)
6
+ @scheduler = scheduler
7
+ end
8
+
9
+ def call(subscriber, _, record)
10
+ run { @scheduler.call(subscriber, record) }
11
+ end
12
+
13
+ def run(&schedule_proc)
14
+ transaction = ActiveRecord::Base.connection.current_transaction
15
+
16
+ if transaction.joinable?
17
+ transaction.add_record(async_record(schedule_proc))
18
+ else
19
+ yield
20
+ end
21
+ end
22
+
23
+ def async_record(schedule_proc)
24
+ AsyncRecord.new(self, schedule_proc)
25
+ end
26
+
27
+ def verify(subscriber)
28
+ @scheduler.verify(subscriber)
29
+ end
30
+
31
+ class AsyncRecord
32
+ def initialize(dispatcher, schedule_proc)
33
+ @dispatcher = dispatcher
34
+ @schedule_proc = schedule_proc
35
+ end
36
+
37
+ def committed!(*)
38
+ schedule_proc.call
39
+ end
40
+
41
+ def rolledback!(*); end
42
+
43
+ def before_committed!; end
44
+
45
+ def add_to_transaction
46
+ dispatcher.run(&schedule_proc)
47
+ end
48
+
49
+ def trigger_transactional_callbacks?; end
50
+
51
+ attr_reader :schedule_proc, :dispatcher
52
+ end
53
+ end
54
+ end
@@ -1,23 +1,32 @@
1
- require 'ruby_event_store'
2
- require 'rails_event_store/active_job_dispatcher'
3
- require 'rails_event_store/client'
4
- require 'rails_event_store/version'
5
- require 'rails_event_store/railtie'
6
- require 'rails_event_store/deprecations'
1
+ # frozen_string_literal: true
2
+
3
+ require "ruby_event_store"
4
+ require_relative "async_handler_helpers"
5
+ require_relative "link_by_metadata"
6
+ require_relative "after_commit_async_dispatcher"
7
+ require_relative "active_job_scheduler"
8
+ require_relative "client"
9
+ require_relative "json_client"
10
+ require_relative "version"
11
+ require_relative "railtie"
12
+ require_relative "browser"
7
13
 
8
14
  module RailsEventStore
9
- Event = RubyEventStore::Event
10
- InMemoryRepository = RubyEventStore::InMemoryRepository
11
- EventBroker = RubyEventStore::PubSub::Broker
12
- Projection = RubyEventStore::Projection
15
+ Event = RubyEventStore::Event
16
+ InMemoryRepository = RubyEventStore::InMemoryRepository
17
+ Subscriptions = RubyEventStore::Subscriptions
18
+ Projection = RubyEventStore::Projection
13
19
  WrongExpectedEventVersion = RubyEventStore::WrongExpectedEventVersion
14
- InvalidExpectedVersion = RubyEventStore::InvalidExpectedVersion
15
- IncorrectStreamData = RubyEventStore::IncorrectStreamData
16
- EventNotFound = RubyEventStore::EventNotFound
17
- SubscriberNotExist = RubyEventStore::SubscriberNotExist
18
- InvalidHandler = RubyEventStore::InvalidHandler
19
- InvalidPageStart = RubyEventStore::InvalidPageStart
20
- InvalidPageSize = RubyEventStore::InvalidPageSize
21
- GLOBAL_STREAM = RubyEventStore::GLOBAL_STREAM
22
- PAGE_SIZE = RubyEventStore::PAGE_SIZE
23
- end
20
+ InvalidExpectedVersion = RubyEventStore::InvalidExpectedVersion
21
+ IncorrectStreamData = RubyEventStore::IncorrectStreamData
22
+ EventNotFound = RubyEventStore::EventNotFound
23
+ SubscriberNotExist = RubyEventStore::SubscriberNotExist
24
+ InvalidHandler = RubyEventStore::InvalidHandler
25
+ InvalidPageStart = RubyEventStore::InvalidPageStart
26
+ InvalidPageStop = RubyEventStore::InvalidPageStop
27
+ InvalidPageSize = RubyEventStore::InvalidPageSize
28
+ CorrelatedCommands = RubyEventStore::CorrelatedCommands
29
+ GLOBAL_STREAM = RubyEventStore::GLOBAL_STREAM
30
+ PAGE_SIZE = RubyEventStore::PAGE_SIZE
31
+ ImmediateAsyncDispatcher = RubyEventStore::ImmediateAsyncDispatcher
32
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsEventStore
4
+ module AsyncHandler
5
+ def self.with_defaults
6
+ with
7
+ end
8
+
9
+ def self.with(
10
+ event_store: Rails.configuration.event_store,
11
+ event_store_locator: nil,
12
+ serializer: RubyEventStore::Serializers::YAML
13
+ )
14
+ Module.new do
15
+ define_method :perform do |payload|
16
+ event_store = event_store_locator.call if event_store_locator
17
+ super(event_store.deserialize(serializer: serializer, **payload.transform_keys(&:to_sym)))
18
+ end
19
+ end
20
+ end
21
+
22
+ def self.prepended(host_class)
23
+ host_class.prepend with_defaults
24
+ end
25
+ end
26
+
27
+ module CorrelatedHandler
28
+ def perform(event)
29
+ Rails
30
+ .configuration
31
+ .event_store
32
+ .with_metadata(correlation_id: event.metadata[:correlation_id], causation_id: event.event_id) { super }
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ruby_event_store/browser/app"
4
+ require "rails/engine"
5
+
6
+ module RailsEventStore
7
+ class Browser < Rails::Engine
8
+ endpoint RubyEventStore::Browser::App.for(event_store_locator: -> { Rails.configuration.event_store })
9
+
10
+ railtie_name "ruby_event_store_browser_app"
11
+ end
12
+ end
@@ -1,33 +1,44 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsEventStore
2
4
  class Client < RubyEventStore::Client
3
5
  attr_reader :request_metadata
4
6
 
5
- def initialize(repository: RailsEventStoreActiveRecord::EventRepository.new,
6
- mapper: RubyEventStore::Mappers::Default.new,
7
- event_broker: EventBroker.new(dispatcher: ActiveJobDispatcher.new),
8
- request_metadata: default_request_metadata,
9
- page_size: PAGE_SIZE)
10
- super(repository: repository,
11
- mapper: mapper,
12
- event_broker: event_broker,
13
- page_size: page_size)
7
+ def initialize(
8
+ mapper: RubyEventStore::Mappers::Default.new,
9
+ repository: RubyEventStore::ActiveRecord::EventRepository.new(serializer: RubyEventStore::Serializers::YAML),
10
+ subscriptions: RubyEventStore::Subscriptions.new,
11
+ dispatcher: RubyEventStore::ComposedDispatcher.new(
12
+ RailsEventStore::AfterCommitAsyncDispatcher.new(
13
+ scheduler: ActiveJobScheduler.new(serializer: RubyEventStore::Serializers::YAML)
14
+ ),
15
+ RubyEventStore::Dispatcher.new
16
+ ),
17
+ clock: default_clock,
18
+ correlation_id_generator: default_correlation_id_generator,
19
+ request_metadata: default_request_metadata
20
+ )
21
+ super(
22
+ repository: RubyEventStore::InstrumentedRepository.new(repository, ActiveSupport::Notifications),
23
+ mapper: RubyEventStore::Mappers::InstrumentedMapper.new(mapper, ActiveSupport::Notifications),
24
+ subscriptions: RubyEventStore::InstrumentedSubscriptions.new(subscriptions, ActiveSupport::Notifications),
25
+ clock: clock,
26
+ correlation_id_generator: correlation_id_generator,
27
+ dispatcher: RubyEventStore::InstrumentedDispatcher.new(dispatcher, ActiveSupport::Notifications)
28
+ )
14
29
  @request_metadata = request_metadata
15
30
  end
16
31
 
17
32
  def with_request_metadata(env, &block)
18
- with_metadata(request_metadata.call(env)) do
19
- block.call
20
- end
33
+ with_metadata(request_metadata.call(env)) { block.call }
21
34
  end
22
35
 
23
36
  private
37
+
24
38
  def default_request_metadata
25
39
  ->(env) do
26
40
  request = ActionDispatch::Request.new(env)
27
- {
28
- remote_ip: request.remote_ip,
29
- request_id: request.uuid
30
- }
41
+ { remote_ip: request.remote_ip, request_id: request.uuid }
31
42
  end
32
43
  end
33
44
  end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsEventStore
4
+ class JSONClient < Client
5
+ def initialize(
6
+ mapper: RubyEventStore::Mappers::Default.new,
7
+ repository: RubyEventStore::ActiveRecord::EventRepository.new(serializer: RubyEventStore::NULL),
8
+ subscriptions: RubyEventStore::Subscriptions.new,
9
+ dispatcher: RubyEventStore::ComposedDispatcher.new(
10
+ RailsEventStore::AfterCommitAsyncDispatcher.new(
11
+ scheduler: ActiveJobScheduler.new(serializer: RubyEventStore::Serializers::YAML)
12
+ ),
13
+ RubyEventStore::Dispatcher.new
14
+ ),
15
+ clock: default_clock,
16
+ correlation_id_generator: default_correlation_id_generator,
17
+ request_metadata: default_request_metadata
18
+ )
19
+ super(
20
+ mapper:
21
+ RubyEventStore::Mappers::InstrumentedMapper.new(
22
+ RubyEventStore::Mappers::PipelineMapper.new(
23
+ RubyEventStore::Mappers::Pipeline.new(
24
+ RubyEventStore::Mappers::Transformation::PreserveTypes
25
+ .new
26
+ .register(Symbol, serializer: ->(v) { v.to_s }, deserializer: ->(v) { v.to_sym })
27
+ .register(
28
+ Time,
29
+ serializer: ->(v) { v.iso8601(RubyEventStore::TIMESTAMP_PRECISION) },
30
+ deserializer: ->(v) { Time.iso8601(v) }
31
+ )
32
+ .register(
33
+ ActiveSupport::TimeWithZone,
34
+ serializer: ->(v) { v.iso8601(RubyEventStore::TIMESTAMP_PRECISION) },
35
+ deserializer: ->(v) { Time.iso8601(v).in_time_zone },
36
+ stored_type: ->(*) { "ActiveSupport::TimeWithZone" }
37
+ )
38
+ .register(Date, serializer: ->(v) { v.iso8601 }, deserializer: ->(v) { Date.iso8601(v) })
39
+ .register(DateTime, serializer: ->(v) { v.iso8601 }, deserializer: ->(v) { DateTime.iso8601(v) })
40
+ .register(BigDecimal, serializer: ->(v) { v.to_s }, deserializer: ->(v) { BigDecimal(v) }),
41
+ RubyEventStore::Mappers::Transformation::SymbolizeMetadataKeys.new
42
+ )
43
+ ),
44
+ ActiveSupport::Notifications
45
+ ),
46
+ repository: RubyEventStore::InstrumentedRepository.new(repository, ActiveSupport::Notifications),
47
+ subscriptions: RubyEventStore::InstrumentedSubscriptions.new(subscriptions, ActiveSupport::Notifications),
48
+ clock: clock,
49
+ correlation_id_generator: correlation_id_generator,
50
+ dispatcher: RubyEventStore::InstrumentedDispatcher.new(dispatcher, ActiveSupport::Notifications)
51
+ )
52
+ @request_metadata = request_metadata
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsEventStore
4
+ class LinkByMetadata < RubyEventStore::LinkByMetadata
5
+ def initialize(event_store: Rails.configuration.event_store, key:, prefix: nil)
6
+ super
7
+ end
8
+ end
9
+
10
+ class LinkByCorrelationId < RubyEventStore::LinkByCorrelationId
11
+ def initialize(event_store: Rails.configuration.event_store, prefix: nil)
12
+ super
13
+ end
14
+ end
15
+
16
+ class LinkByCausationId < RubyEventStore::LinkByCausationId
17
+ def initialize(event_store: Rails.configuration.event_store, prefix: nil)
18
+ super
19
+ end
20
+ end
21
+
22
+ class LinkByEventType < RubyEventStore::LinkByEventType
23
+ def initialize(event_store: Rails.configuration.event_store, prefix: nil)
24
+ super
25
+ end
26
+ end
27
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsEventStore
2
4
  class Middleware
3
5
  def initialize(app)
@@ -6,9 +8,7 @@ module RailsEventStore
6
8
 
7
9
  def call(env)
8
10
  if config.respond_to?(:event_store)
9
- config.event_store.with_request_metadata(env) do
10
- @app.call(env)
11
- end
11
+ config.event_store.with_request_metadata(env) { @app.call(env) }
12
12
  else
13
13
  @app.call(env)
14
14
  end
@@ -1,11 +1,12 @@
1
- require 'rails/railtie'
2
- require 'rails_event_store/middleware'
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/railtie"
4
+ require_relative "middleware"
3
5
 
4
6
  module RailsEventStore
5
7
  class Railtie < ::Rails::Railtie
6
- initializer 'rails_event_store.middleware' do |rails|
8
+ initializer "rails_event_store.middleware" do |rails|
7
9
  rails.middleware.use(::RailsEventStore::Middleware)
8
10
  end
9
11
  end
10
12
  end
11
-
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsEventStore
2
- VERSION = "0.30.0"
4
+ VERSION = "2.9.1"
3
5
  end
@@ -1,2 +1,4 @@
1
- require 'rails_event_store_active_record'
2
- require 'rails_event_store/all'
1
+ # frozen_string_literal: true
2
+
3
+ require "rails_event_store_active_record"
4
+ require_relative "rails_event_store/all"
metadata CHANGED
@@ -1,225 +1,113 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_event_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.30.0
4
+ version: 2.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arkency
8
- autorequire:
9
- bindir: exe
8
+ autorequire:
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-31 00:00:00.000000000 Z
11
+ date: 2023-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.15'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.15'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '10.0'
41
- - !ruby/object:Gem::Dependency
42
- name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '3.6'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '3.6'
55
- - !ruby/object:Gem::Dependency
56
- name: rails
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '5.2'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '5.2'
69
- - !ruby/object:Gem::Dependency
70
- name: sqlite3
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: rack-test
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: mutant-rspec
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: 0.8.14
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: 0.8.14
111
- - !ruby/object:Gem::Dependency
112
- name: google-protobuf
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: 3.5.1.2
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: 3.5.1.2
125
13
  - !ruby/object:Gem::Dependency
126
14
  name: ruby_event_store
127
15
  requirement: !ruby/object:Gem::Requirement
128
16
  requirements:
129
17
  - - '='
130
18
  - !ruby/object:Gem::Version
131
- version: 0.30.0
19
+ version: 2.9.1
132
20
  type: :runtime
133
21
  prerelease: false
134
22
  version_requirements: !ruby/object:Gem::Requirement
135
23
  requirements:
136
24
  - - '='
137
25
  - !ruby/object:Gem::Version
138
- version: 0.30.0
26
+ version: 2.9.1
139
27
  - !ruby/object:Gem::Dependency
140
- name: rails_event_store_active_record
28
+ name: ruby_event_store-browser
141
29
  requirement: !ruby/object:Gem::Requirement
142
30
  requirements:
143
31
  - - '='
144
32
  - !ruby/object:Gem::Version
145
- version: 0.30.0
33
+ version: 2.9.1
146
34
  type: :runtime
147
35
  prerelease: false
148
36
  version_requirements: !ruby/object:Gem::Requirement
149
37
  requirements:
150
38
  - - '='
151
39
  - !ruby/object:Gem::Version
152
- version: 0.30.0
40
+ version: 2.9.1
153
41
  - !ruby/object:Gem::Dependency
154
- name: aggregate_root
42
+ name: rails_event_store_active_record
155
43
  requirement: !ruby/object:Gem::Requirement
156
44
  requirements:
157
45
  - - '='
158
46
  - !ruby/object:Gem::Version
159
- version: 0.30.0
47
+ version: 2.9.1
160
48
  type: :runtime
161
49
  prerelease: false
162
50
  version_requirements: !ruby/object:Gem::Requirement
163
51
  requirements:
164
52
  - - '='
165
53
  - !ruby/object:Gem::Version
166
- version: 0.30.0
54
+ version: 2.9.1
167
55
  - !ruby/object:Gem::Dependency
168
- name: bounded_context
56
+ name: aggregate_root
169
57
  requirement: !ruby/object:Gem::Requirement
170
58
  requirements:
171
59
  - - '='
172
60
  - !ruby/object:Gem::Version
173
- version: 0.30.0
61
+ version: 2.9.1
174
62
  type: :runtime
175
63
  prerelease: false
176
64
  version_requirements: !ruby/object:Gem::Requirement
177
65
  requirements:
178
66
  - - '='
179
67
  - !ruby/object:Gem::Version
180
- version: 0.30.0
68
+ version: 2.9.1
181
69
  - !ruby/object:Gem::Dependency
182
70
  name: activesupport
183
71
  requirement: !ruby/object:Gem::Requirement
184
72
  requirements:
185
73
  - - ">="
186
74
  - !ruby/object:Gem::Version
187
- version: '3.0'
75
+ version: '6.0'
188
76
  type: :runtime
189
77
  prerelease: false
190
78
  version_requirements: !ruby/object:Gem::Requirement
191
79
  requirements:
192
80
  - - ">="
193
81
  - !ruby/object:Gem::Version
194
- version: '3.0'
82
+ version: '6.0'
195
83
  - !ruby/object:Gem::Dependency
196
84
  name: activemodel
197
85
  requirement: !ruby/object:Gem::Requirement
198
86
  requirements:
199
87
  - - ">="
200
88
  - !ruby/object:Gem::Version
201
- version: '3.0'
89
+ version: '6.0'
202
90
  type: :runtime
203
91
  prerelease: false
204
92
  version_requirements: !ruby/object:Gem::Requirement
205
93
  requirements:
206
94
  - - ">="
207
95
  - !ruby/object:Gem::Version
208
- version: '3.0'
96
+ version: '6.0'
209
97
  - !ruby/object:Gem::Dependency
210
98
  name: activejob
211
99
  requirement: !ruby/object:Gem::Requirement
212
100
  requirements:
213
101
  - - ">="
214
102
  - !ruby/object:Gem::Version
215
- version: '3.0'
103
+ version: '6.0'
216
104
  type: :runtime
217
105
  prerelease: false
218
106
  version_requirements: !ruby/object:Gem::Requirement
219
107
  requirements:
220
108
  - - ">="
221
109
  - !ruby/object:Gem::Version
222
- version: '3.0'
110
+ version: '6.0'
223
111
  - !ruby/object:Gem::Dependency
224
112
  name: arkency-command_bus
225
113
  requirement: !ruby/object:Gem::Requirement
@@ -234,36 +122,48 @@ dependencies:
234
122
  - - ">="
235
123
  - !ruby/object:Gem::Version
236
124
  version: '0.4'
237
- description: Implementation of Event Store in Ruby
238
- email:
239
- - dev@arkency.com
125
+ description: |
126
+ Rails wrapper for RubyEventStore with batteries included. Ships with asynchronous after-commit event dispatch
127
+ on top of ActiveJob, ActiveSupport::Notifications instrumentation enabled, request metadata enrichment
128
+ and opinionated directory structure generator for bounded contexts.
129
+ email: dev@arkency.com
240
130
  executables: []
241
131
  extensions: []
242
- extra_rdoc_files: []
132
+ extra_rdoc_files:
133
+ - README.md
243
134
  files:
244
- - CHANGELOG.md
245
- - Gemfile
246
- - Makefile
247
135
  - README.md
136
+ - lib/generators/rails_event_store/bounded_context_generator.rb
137
+ - lib/generators/rails_event_store/rspec_generator.rb
138
+ - lib/generators/rails_event_store/test_unit_generator.rb
139
+ - lib/generators/templates/bc_spec.rb
140
+ - lib/generators/templates/module.rb
141
+ - lib/generators/templates/require_bc_spec.rb
142
+ - lib/generators/templates/require_bc_test.rb
143
+ - lib/generators/templates/spec_helper.rb
144
+ - lib/generators/templates/test_helper.rb
248
145
  - lib/rails_event_store.rb
249
- - lib/rails_event_store/active_job_dispatcher.rb
146
+ - lib/rails_event_store/active_job_scheduler.rb
147
+ - lib/rails_event_store/after_commit_async_dispatcher.rb
250
148
  - lib/rails_event_store/all.rb
149
+ - lib/rails_event_store/async_handler_helpers.rb
150
+ - lib/rails_event_store/browser.rb
251
151
  - lib/rails_event_store/client.rb
252
- - lib/rails_event_store/deprecations.rb
152
+ - lib/rails_event_store/json_client.rb
153
+ - lib/rails_event_store/link_by_metadata.rb
253
154
  - lib/rails_event_store/middleware.rb
254
155
  - lib/rails_event_store/railtie.rb
255
156
  - lib/rails_event_store/version.rb
256
- - rails_event_store.gemspec
257
- - tmp/.keep
258
157
  homepage: https://railseventstore.org
259
158
  licenses:
260
159
  - MIT
261
160
  metadata:
262
- homepage_uri: https://railseventstore.org/
161
+ homepage_uri: https://railseventstore.org
263
162
  changelog_uri: https://github.com/RailsEventStore/rails_event_store/releases
264
163
  source_code_uri: https://github.com/RailsEventStore/rails_event_store
265
164
  bug_tracker_uri: https://github.com/RailsEventStore/rails_event_store/issues
266
- post_install_message:
165
+ rubygems_mfa_required: 'true'
166
+ post_install_message:
267
167
  rdoc_options: []
268
168
  require_paths:
269
169
  - lib
@@ -271,16 +171,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
271
171
  requirements:
272
172
  - - ">="
273
173
  - !ruby/object:Gem::Version
274
- version: '0'
174
+ version: '2.7'
275
175
  required_rubygems_version: !ruby/object:Gem::Requirement
276
176
  requirements:
277
177
  - - ">="
278
178
  - !ruby/object:Gem::Version
279
179
  version: '0'
280
180
  requirements: []
281
- rubyforge_project:
282
- rubygems_version: 2.7.6
283
- signing_key:
181
+ rubygems_version: 3.3.7
182
+ signing_key:
284
183
  specification_version: 4
285
- summary: Event Store in Ruby
184
+ summary: Rails wrapper for RubyEventStore with batteries included
286
185
  test_files: []
data/CHANGELOG.md DELETED
@@ -1,159 +0,0 @@
1
- Further changes can be tracked at [releases page](https://github.com/RailsEventStore/rails_event_store/releases).
2
-
3
- ### 0.14.5 (24.08.2017)
4
-
5
- * Change: ruby_event_store updated to 0.14.0
6
-
7
- ### 0.14.4 (18.08.2017)
8
-
9
- * Change: rails_event_store_active_record updated to 0.6.11
10
- * Fix: Explicit order when querying forward. Leaving it implcit to database engine choice gives different results on different engines.
11
- * Fix: Explicitly require railtie to load middleware in Rails to enrich event metadata with request metadata (PR #65)
12
-
13
- ### 0.14.3 (24.11.2016)
14
-
15
- * Fix: Fixes where is initialized event repository #62
16
-
17
- ### 0.14.2 (23.11.2016)
18
-
19
- * Change: rails_event_store_active_record updated to 0.6.10
20
- This time it will really allow to avoid ActiveRecord dependency when not using rails_event_store_active_record's
21
- event repository.
22
-
23
- ### 0.14.1 (21.11.2016)
24
-
25
- * Change: Allows to set the event repository used. #61
26
- Allow to avoid ActiveRecord dependency when not using rails_event_store_active_record's
27
- event repository. See documentation for mode details https://railseventstore.arkency.com/docs/repository.html
28
-
29
- ### 0.14.0 (28.10.2016)
30
-
31
- * Change: aggregate_root updated to 0.4.0
32
- This is a breaking change only if you use aggregate_root gem.
33
- Nothing has changed in RailsEventStore however the aggregate_root gem
34
- has been redesigned completely.
35
-
36
- ### 0.13.0 (21.10.2016)
37
-
38
- * Change: ruby_event_store updated to 0.13.0
39
- * Change: RailsEventStore::Client methods signarures aligned with RubyEventStore::Client
40
- RailsEventStore::Client is just a specialization of RubyEventStore::Client
41
- with sensible defaults. Nothing more. This will ensure both are compatible.
42
- * Change: No more ClosedStruct in Event class, you need use hashes to access data & metadata.
43
- This is a breaking change.
44
-
45
- ### 0.12.1 (11.08.2016)
46
-
47
- * Fix: aggregate_root gem updated to 0.3.5 fixing invalid method name generated for events wrapped in namespace
48
-
49
- ### 0.12.0 (10.08.2016)
50
-
51
- * Change: Updated Ruby Event Store method calls according to the newer version PR #53
52
-
53
- ### 0.11.0 (12.07.2016)
54
-
55
- * Breaking change in domain event class (Part of PR #48)
56
- * no more simple `TestEvent.new(some_attr: 'some value')`
57
- use `TestEvent.new(data: { some_attr: 'some value' })` instead
58
- * all data & metadata attributes accessible via `data` & `metadata` properties
59
- of event class
60
- * This will avoid name clashes when defining domain event data,
61
- especially important for `event_id`
62
- * Breaking change: deprecated `handle_event` method removed, use `call` instead
63
- * some domain event handlers might need method rename
64
- * Change: Mark aliased methods as deprecated (soon to be removed)
65
- * Change: Update RubyEventStore to 0.11.0 PR #48
66
- * RubyEventStore::Facade renamed to RubyEventStore::Client
67
- * Fix: Improve mutation tests coverage PR #47
68
-
69
- ### 0.10.0 (30.06.2016)
70
-
71
- * Change: Rails request details in event metadata PR #39
72
- * Change: Add dynamic subscriptions (implemented by ruby_event_store 0.9.0) PR #43
73
- * Fix: In-memory sqlite3 with schema load over prebaked filesystem blob in testing PR #41
74
-
75
- ### 0.9.0 (24.06.2016)
76
-
77
- * Change: ruby_event_store updated to 0.9.0 (Call instead of handle_event)
78
- * Change: aggregate_root updated to 0.3.1 (licensing info)
79
- * Fix: Clarify Licensing terms #36 - MIT licence it is from now
80
-
81
- ### 0.8.0 (21.06.2016)
82
-
83
- * Change: ruby_event_store updated to 0.8.0 (dynamic subscriptions)
84
- * Change: aggregate_root updated to 0.3.0 (fix circular dependency)
85
- * Change: remove SlackEventHandler
86
-
87
- ### 0.7.0 (01.06.2016)
88
-
89
- * Change: ruby_event_store updated to 0.6.0 (adding basic projections support)
90
-
91
- ### 0.6.1 (25.05.2016)
92
-
93
- * Fix: Allow to read events backward PR #32 (bugfix)
94
-
95
- ### 0.6.0 (11.04.2016)
96
-
97
- * Change: EventRepository moved to separate gem [rails_event_store_active_record](https://github.com/RailsEventStore/rails_event_store_active_record)
98
- * Change: rails_event_store_active_record updated to version 0.5.1 - allows to use custom event class
99
-
100
- ### 0.5.0 (21.03.2016)
101
-
102
- * Align with changes in `ruby_event_store` 0.5.0:
103
- * Change: Event class refactoring to make default values more explicit
104
- * Change: Let event broker to be given as a dependency
105
- * Change: No nils, use symbols instead - :any & :none replaced meaningless nil value
106
- * Change: Remove Event#event_type - use class instead
107
- * Fix: Typo fix (appent_to_stream corrected to append_to_stream)
108
- * Change: Encapsulate internals fo RailsEventStore::Client
109
- * Change: Hide `ruby_event_store` internals by adding classes in RailsEventStore module
110
-
111
- ### 0.4.1 (17.03.2016)
112
-
113
- * Fix: aggregate_root gem aligned with changes in rails_event_store
114
-
115
- ### 0.4.0 (17.03.2016)
116
-
117
- * Change: Use class names to subscribe events (ruby_event_store update to 0.4.0)
118
- * Change: EventRepository now recreate events using orginal classes
119
-
120
- ### 0.3.1 (13.03.2016)
121
-
122
- * Update to ruby_event_store 0.3.1 - fix changing timestamp on reads from repository
123
-
124
- ### 0.3.0 (03.03.2016)
125
-
126
- * Update to ruby_event_store 0.3.0 - see ruby_event_store changelog for more details
127
- * Implement reading forward & backward (aliasold methods to read forward)
128
- * Implement paging when reading from all streams
129
-
130
- ### 0.2.2 (25.02.2016)
131
-
132
- * Restore AggregateRoot in RES, but this time as a dependency on aggregate_root gem
133
-
134
- ### 0.2.1 (25.02.2016)
135
-
136
- * Fix: Error when trying to #read_all_streams #20
137
-
138
- ### 0.2.0 (29.01.2016)
139
-
140
- * Removed EventEntity class
141
- * All read & returned events are not instances of RailsEventStore::Event class
142
- * RailsEventStore::Event class allows for easier events creation and access to data attributes
143
- * AggregateRoot module & repository extracted to new gem (aggregate_root)
144
-
145
- ### 0.1.2 (26.05.2015)
146
-
147
- * Moved most core features to the separate gem `ruby_event_store`. We left only rails related implementation here.
148
- * It's now assumed that `event_id` has a unique index in the database (the same is applied to the initial migration generator)
149
- * Model is no longer validating uniqueness of `event_id` via ActiveRecord
150
- * Event does not need any data now, it can be created just like `OrderCreated.new` (without any arguments)
151
- * Migration generator is no more generating the `updated_at` field in the `event_store_events` table. We also advise to remove this column, since events shouldn't be *ever* modified.
152
- * In the event's metadata there's a new field `published_at`
153
- * Added the `subscribe_to_all_events` method to `RailsEventStore::Client`
154
- * Subscribing to only one event via `client.subscribe(subscriber, 'OrderCreated')` no longer works. You should use `client.subscribe(subscriber, ['OrderCreated'])` instead.
155
- * Default event's name is no longer `OrderCreated` for the `OrderCreated` event in the `Orders` namespace, now it's `Orders::OrderCreated`
156
-
157
- ### 0.1.1 (22.04.2015)
158
-
159
- Initial release.
data/Gemfile DELETED
@@ -1,12 +0,0 @@
1
- source 'https://rubygems.org'
2
- gemspec
3
-
4
- gem 'ruby_event_store', path: '../ruby_event_store'
5
- gem 'rails_event_store_active_record', path: '../rails_event_store_active_record'
6
- gem 'aggregate_root', path: '../aggregate_root'
7
- gem 'bounded_context', path: '../bounded_context'
8
- gem 'protobuf_nested_struct'
9
-
10
- if v = ENV['RAILS_VERSION']
11
- gem 'rails', v
12
- end
data/Makefile DELETED
@@ -1,49 +0,0 @@
1
- GEM_VERSION = $(shell cat ../RES_VERSION)
2
- GEM_NAME = rails_event_store
3
- REQUIRE = $(GEM_NAME)
4
- IGNORE = RailsEventStore.const_missing \
5
- RailsEventStore::Client\#initialize \
6
- RailsEventStore::AsyncProxyStrategy::AfterCommit::AsyncRecord\#rolledback! \
7
- RailsEventStore::AsyncProxyStrategy::AfterCommit::AsyncRecord\#before_committed!
8
- SUBJECT ?= RailsEventStore*
9
-
10
- install: ## Install gem dependencies
11
- @echo "Installing gem dependencies"
12
- @bundle install
13
-
14
- remove-lock:
15
- @echo "Removing resolved dependency versions"
16
- -rm Gemfile.lock
17
-
18
- reinstall: remove-lock install ## Removing resolved dependency versions
19
-
20
- test: ## Run unit tests
21
- @echo "Running unit tests"
22
- @bundle exec rspec
23
-
24
- mutate: test ## Run mutation tests
25
- @echo "Running mutation tests"
26
- @bundle exec mutant --include lib \
27
- $(addprefix --require ,$(REQUIRE)) \
28
- $(addprefix --ignore-subject ,$(IGNORE)) \
29
- --use rspec "$(SUBJECT)"
30
-
31
- build:
32
- @echo "Building gem package"
33
- @gem build -V $(GEM_NAME).gemspec
34
- @mkdir -p pkg/
35
- @mv $(GEM_NAME)-$(GEM_VERSION).gem pkg/
36
-
37
- push:
38
- @echo "Pushing package to RubyGems"
39
- @gem push -k dev_arkency pkg/$(GEM_NAME)-$(GEM_VERSION).gem
40
-
41
- clean:
42
- @echo "Removing previously built package"
43
- -rm pkg/$(GEM_NAME)-$(GEM_VERSION).gem
44
-
45
- help:
46
- @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
47
-
48
- .PHONY: help
49
- .DEFAULT_GOAL := help
@@ -1,71 +0,0 @@
1
- require 'active_job'
2
-
3
- module RailsEventStore
4
- module AsyncProxyStrategy
5
- class AfterCommit
6
- def call(klass, event)
7
- if ActiveRecord::Base.connection.transaction_open?
8
- ActiveRecord::Base.
9
- connection.
10
- current_transaction.
11
- add_record(AsyncRecord.new(klass, event))
12
- else
13
- klass.perform_later(YAML.dump(event))
14
- end
15
- end
16
-
17
- private
18
- class AsyncRecord
19
- def initialize(klass, event)
20
- @klass = klass
21
- @event = event
22
- end
23
-
24
- def committed!
25
- @klass.perform_later(YAML.dump(@event))
26
- end
27
-
28
- def rolledback!(*)
29
- end
30
-
31
- def before_committed!
32
- end
33
-
34
- def add_to_transaction
35
- AfterCommit.new.call(@klass, @event)
36
- end
37
- end
38
- end
39
-
40
- class Inline
41
- def call(klass, event)
42
- klass.perform_later(YAML.dump(event))
43
- end
44
- end
45
- end
46
-
47
- class ActiveJobDispatcher < RubyEventStore::PubSub::Dispatcher
48
- def initialize(proxy_strategy: AsyncProxyStrategy::Inline.new)
49
- @async_proxy_strategy = proxy_strategy
50
- end
51
-
52
- def call(subscriber, event)
53
- if async_handler?(subscriber)
54
- @async_proxy_strategy.call(subscriber, event)
55
- else
56
- super
57
- end
58
- end
59
-
60
- def verify(subscriber)
61
- super unless async_handler?(subscriber)
62
- end
63
-
64
- private
65
-
66
- def async_handler?(klass)
67
- Class === klass && klass < ActiveJob::Base
68
- end
69
-
70
- end
71
- end
@@ -1,7 +0,0 @@
1
- module RailsEventStore
2
- def self.const_missing(const_name)
3
- super unless const_name == :MethodNotDefined
4
- warn "`RailsEventStore::MethodNotDefined` has been deprecated. Use `RailsEventStore::InvalidHandler` instead."
5
- InvalidHandler
6
- end
7
- end
@@ -1,45 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'rails_event_store/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'rails_event_store'
8
- spec.version = RailsEventStore::VERSION
9
- spec.licenses = ['MIT']
10
- spec.authors = ['Arkency']
11
- spec.email = ['dev@arkency.com']
12
-
13
- spec.summary = %q{Event Store in Ruby}
14
- spec.description = %q{Implementation of Event Store in Ruby}
15
- spec.homepage = 'https://railseventstore.org'
16
- spec.metadata = {
17
- "homepage_uri" => "https://railseventstore.org/",
18
- "changelog_uri" => "https://github.com/RailsEventStore/rails_event_store/releases",
19
- "source_code_uri" => "https://github.com/RailsEventStore/rails_event_store",
20
- "bug_tracker_uri" => "https://github.com/RailsEventStore/rails_event_store/issues",
21
- }
22
-
23
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
- spec.bindir = 'exe'
25
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
- spec.require_paths = ['lib']
27
-
28
- spec.add_development_dependency 'bundler', '~> 1.15'
29
- spec.add_development_dependency 'rake', '~> 10.0'
30
- spec.add_development_dependency 'rspec', '~> 3.6'
31
- spec.add_development_dependency 'rails', '~> 5.2'
32
- spec.add_development_dependency 'sqlite3'
33
- spec.add_development_dependency 'rack-test'
34
- spec.add_development_dependency 'mutant-rspec', '~> 0.8.14'
35
- spec.add_development_dependency 'google-protobuf', '~> 3.5.1.2'
36
-
37
- spec.add_dependency 'ruby_event_store', '= 0.30.0'
38
- spec.add_dependency 'rails_event_store_active_record', '= 0.30.0'
39
- spec.add_dependency 'aggregate_root', '= 0.30.0'
40
- spec.add_dependency 'bounded_context', '= 0.30.0'
41
- spec.add_dependency 'activesupport', '>= 3.0'
42
- spec.add_dependency 'activemodel', '>= 3.0'
43
- spec.add_dependency 'activejob', '>= 3.0'
44
- spec.add_dependency 'arkency-command_bus', '>= 0.4'
45
- end
data/tmp/.keep DELETED
File without changes