sequent 7.0.0 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'support/database'
4
- require_relative 'support/view_projection'
5
- require_relative 'support/view_schema'
@@ -4,3 +4,4 @@ require_relative 'skip_if_already_processing'
4
4
  require_relative 'timer'
5
5
  require_relative 'printer'
6
6
  require_relative 'dry_run'
7
+ require_relative 'web/clear_cache'
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sequent
4
+ module Util
5
+ module Web
6
+ class ClearCache
7
+ def initialize(app)
8
+ @app = app
9
+ end
10
+
11
+ def call(env)
12
+ @app.call(env)
13
+ ensure
14
+ Sequent.aggregate_repository.clear!
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
data/lib/sequent.rb CHANGED
@@ -5,5 +5,6 @@ require_relative 'sequent/sequent'
5
5
  require_relative 'sequent/core/core'
6
6
  require_relative 'sequent/util/util'
7
7
  require_relative 'sequent/migrations/migrations'
8
+ require_relative 'sequent/dry_run/dry_run'
8
9
 
9
10
  require_relative 'notices'
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sequent
4
- VERSION = '7.0.0'
4
+ VERSION = '7.1.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequent
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.0
4
+ version: 7.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lars Vonk
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2023-11-02 00:00:00.000000000 Z
15
+ date: 2024-09-26 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activemodel
@@ -20,40 +20,28 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: '5.0'
24
- - - "<"
25
- - !ruby/object:Gem::Version
26
- version: '7.2'
23
+ version: '6.0'
27
24
  type: :runtime
28
25
  prerelease: false
29
26
  version_requirements: !ruby/object:Gem::Requirement
30
27
  requirements:
31
28
  - - ">="
32
29
  - !ruby/object:Gem::Version
33
- version: '5.0'
34
- - - "<"
35
- - !ruby/object:Gem::Version
36
- version: '7.2'
30
+ version: '6.0'
37
31
  - !ruby/object:Gem::Dependency
38
32
  name: activerecord
39
33
  requirement: !ruby/object:Gem::Requirement
40
34
  requirements:
41
35
  - - ">="
42
36
  - !ruby/object:Gem::Version
43
- version: '5.0'
44
- - - "<"
45
- - !ruby/object:Gem::Version
46
- version: '7.2'
37
+ version: '6.0'
47
38
  type: :runtime
48
39
  prerelease: false
49
40
  version_requirements: !ruby/object:Gem::Requirement
50
41
  requirements:
51
42
  - - ">="
52
43
  - !ruby/object:Gem::Version
53
- version: '5.0'
54
- - - "<"
55
- - !ruby/object:Gem::Version
56
- version: '7.2'
44
+ version: '6.0'
57
45
  - !ruby/object:Gem::Dependency
58
46
  name: bcrypt
59
47
  requirement: !ruby/object:Gem::Requirement
@@ -119,7 +107,7 @@ dependencies:
119
107
  version: 2.6.5
120
108
  - - "<"
121
109
  - !ruby/object:Gem::Version
122
- version: '3.3'
110
+ version: '3.4'
123
111
  type: :runtime
124
112
  prerelease: false
125
113
  version_requirements: !ruby/object:Gem::Requirement
@@ -129,7 +117,7 @@ dependencies:
129
117
  version: 2.6.5
130
118
  - - "<"
131
119
  - !ruby/object:Gem::Version
132
- version: '3.3'
120
+ version: '3.4'
133
121
  - !ruby/object:Gem::Dependency
134
122
  name: pg
135
123
  requirement: !ruby/object:Gem::Requirement
@@ -176,16 +164,16 @@ dependencies:
176
164
  name: tzinfo
177
165
  requirement: !ruby/object:Gem::Requirement
178
166
  requirements:
179
- - - "~>"
167
+ - - ">="
180
168
  - !ruby/object:Gem::Version
181
- version: '2.0'
169
+ version: '1.1'
182
170
  type: :runtime
183
171
  prerelease: false
184
172
  version_requirements: !ruby/object:Gem::Requirement
185
173
  requirements:
186
- - - "~>"
174
+ - - ">="
187
175
  - !ruby/object:Gem::Version
188
- version: '2.0'
176
+ version: '1.1'
189
177
  - !ruby/object:Gem::Dependency
190
178
  name: pry
191
179
  requirement: !ruby/object:Gem::Requirement
@@ -358,7 +346,6 @@ files:
358
346
  - lib/sequent/core/helpers/equal_support.rb
359
347
  - lib/sequent/core/helpers/helpers.rb
360
348
  - lib/sequent/core/helpers/mergable.rb
361
- - lib/sequent/core/helpers/message_dispatcher.rb
362
349
  - lib/sequent/core/helpers/message_handler.rb
363
350
  - lib/sequent/core/helpers/message_handler_option_registry.rb
364
351
  - lib/sequent/core/helpers/message_matchers/any.rb
@@ -396,6 +383,9 @@ files:
396
383
  - lib/sequent/core/transactions/transactions.rb
397
384
  - lib/sequent/core/value_object.rb
398
385
  - lib/sequent/core/workflow.rb
386
+ - lib/sequent/dry_run/dry_run.rb
387
+ - lib/sequent/dry_run/read_only_replay_optimized_postgres_persistor.rb
388
+ - lib/sequent/dry_run/view_schema.rb
399
389
  - lib/sequent/generator.rb
400
390
  - lib/sequent/generator/aggregate.rb
401
391
  - lib/sequent/generator/command.rb
@@ -428,6 +418,7 @@ files:
428
418
  - lib/sequent/generator/template_project/spec/app/projectors/post_projector_spec.rb
429
419
  - lib/sequent/generator/template_project/spec/lib/post/post_command_handler_spec.rb
430
420
  - lib/sequent/generator/template_project/spec/spec_helper.rb
421
+ - lib/sequent/migrations/errors.rb
431
422
  - lib/sequent/migrations/executor.rb
432
423
  - lib/sequent/migrations/functions.rb
433
424
  - lib/sequent/migrations/migrations.rb
@@ -435,13 +426,12 @@ files:
435
426
  - lib/sequent/migrations/projectors.rb
436
427
  - lib/sequent/migrations/sequent_schema.rb
437
428
  - lib/sequent/migrations/sql.rb
429
+ - lib/sequent/migrations/versions.rb
438
430
  - lib/sequent/migrations/view_schema.rb
439
431
  - lib/sequent/rake/migration_tasks.rb
440
432
  - lib/sequent/sequent.rb
441
433
  - lib/sequent/support.rb
442
434
  - lib/sequent/support/database.rb
443
- - lib/sequent/support/view_projection.rb
444
- - lib/sequent/support/view_schema.rb
445
435
  - lib/sequent/test.rb
446
436
  - lib/sequent/test/command_handler_helpers.rb
447
437
  - lib/sequent/test/database_helpers.rb
@@ -453,6 +443,7 @@ files:
453
443
  - lib/sequent/util/skip_if_already_processing.rb
454
444
  - lib/sequent/util/timer.rb
455
445
  - lib/sequent/util/util.rb
446
+ - lib/sequent/util/web/clear_cache.rb
456
447
  - lib/version.rb
457
448
  homepage: https://github.com/zilverline/sequent
458
449
  licenses:
@@ -466,14 +457,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
466
457
  requirements:
467
458
  - - ">="
468
459
  - !ruby/object:Gem::Version
469
- version: '2.7'
460
+ version: '3.0'
470
461
  required_rubygems_version: !ruby/object:Gem::Requirement
471
462
  requirements:
472
463
  - - ">="
473
464
  - !ruby/object:Gem::Version
474
465
  version: '0'
475
466
  requirements: []
476
- rubygems_version: 3.4.10
467
+ rubygems_version: 3.5.16
477
468
  signing_key:
478
469
  specification_version: 4
479
470
  summary: Event sourcing framework for Ruby
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sequent
4
- module Core
5
- module Helpers
6
- class MessageDispatcher
7
- def initialize(message_router, context)
8
- @message_router = message_router
9
- @context = context
10
- end
11
-
12
- def dispatch_message(message)
13
- @message_router
14
- .match_message(message)
15
- .each do |handler|
16
- Sequent.logger.debug("[MessageDispatcher] Handler #{@context.class} handling #{message.class}")
17
- @context.instance_exec(message, &handler)
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'postgresql_cursor'
4
-
5
- module Sequent
6
- module Support
7
- class ViewProjection
8
- attr_reader :name, :version, :schema_definition
9
-
10
- def initialize(options)
11
- @name = options.fetch(:name)
12
- @version = options.fetch(:version)
13
- @schema_definition = options.fetch(:definition)
14
- @replay_event_handlers = options.fetch(:event_handlers)
15
- end
16
-
17
- def build!
18
- with_default_configuration do
19
- Sequent.configuration.event_handlers = @replay_event_handlers
20
-
21
- load schema_definition
22
- event_store = Sequent.configuration.event_store
23
- ordering = Events::ORDERED_BY_STREAM
24
- event_store.replay_events_from_cursor(
25
- block_size: 10_000,
26
- get_events: -> { ordering[event_store] },
27
- )
28
- end
29
- end
30
-
31
- def schema_name
32
- "#{name}_#{version}"
33
- end
34
-
35
- private
36
-
37
- def with_default_configuration
38
- original_configuration = Sequent.configuration
39
- Sequent::Configuration.reset
40
- yield
41
- Sequent::Configuration.restore(original_configuration)
42
- end
43
- end
44
-
45
- module Events
46
- extend ActiveRecord::ConnectionAdapters::Quoting
47
-
48
- ORDERED_BY_STREAM = ->(_event_store) do
49
- event_records = quote_table_name(Sequent.configuration.event_record_class.table_name)
50
- stream_records = quote_table_name(Sequent.configuration.stream_record_class.table_name)
51
- snapshot_event_type = quote(Sequent.configuration.snapshot_event_class)
52
-
53
- Sequent.configuration.event_record_class
54
- .select('event_type, event_json')
55
- .joins("INNER JOIN #{stream_records} ON #{event_records}.stream_record_id = #{stream_records}.id")
56
- .where("event_type <> #{snapshot_event_type}")
57
- .order!("#{stream_records}.id, #{event_records}.sequence_number")
58
- end
59
- end
60
- end
61
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sequent
4
- module Support
5
- class ViewSchema < ActiveRecord::Schema
6
- def define(info, &block)
7
- view_projection = info[:view_projection]
8
- switch_to_schema(view_projection) if view_projection
9
- super
10
- ensure
11
- switch_back_to_original_schema if view_projection
12
- end
13
-
14
- def switch_to_schema(view_projection)
15
- @original_schema_search_path = connection.schema_search_path
16
- connection.schema_search_path = view_projection.schema_name
17
- end
18
-
19
- def switch_back_to_original_schema
20
- connection.schema_search_path = @original_schema_search_path
21
- end
22
- end
23
- end
24
- end