event_sourcery-postgres 0.6.0 → 0.9.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c2860efca21f5ae2a7a8ae316ea70db1fcb1aa1e
4
- data.tar.gz: 56fe6bc5b9233ffc8795ba6b37cff8763bf1b166
2
+ SHA256:
3
+ metadata.gz: 1f48f164ba06d6ca1b51c7689644310bc107a37c9501db547a6c70214e41166d
4
+ data.tar.gz: 9fa2c3bf874a0bc938c942c65c582c63ea02b48e7ae02fbd535928acc2d4b267
5
5
  SHA512:
6
- metadata.gz: 8b1ef120a33fa76da1698f68a063c07293d82ff1a8310682dbf7be812156216c18061ad7fb5706d412d03f60a67dc1dbd33d05637c12891018fb2cdd7cfbbd42
7
- data.tar.gz: 9310dbd856abac2ffe24f9a6b78f1fc3b6baf23ecfdf087fa5e2349210c343a1f4533c876df9fb5e21107cd5e7bf5fd197fe8cc8fbe4a5eea56ce96aa67c7f37
6
+ metadata.gz: a5136b5f830ee26b5c7899a3a44e7505c8752ba9ca02d9c739ba0a0eae59bd72c295f208c5a0743e36b53df77b55d4b9fe5126def654c128b3f7b92354871f05
7
+ data.tar.gz: 1fc7ba4cbc1661b7b634e91b501adc5e136b6285a184c382f1915865c41a62c634179f035bd1e94734feba03b0a3307ab3951953b1de87f783a2ee726f630db0
data/CHANGELOG.md CHANGED
@@ -1,10 +1,65 @@
1
1
  # Change Log
2
+
2
3
  All notable changes to this project will be documented in this file.
3
4
 
4
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
6
  and this project adheres to [Semantic Versioning](http://semver.org/).
6
7
 
7
- ## [0.6.0] - 2018-1-2
8
+ ## [Unreleased]
9
+ ## [0.9.0] - 2021-11-18
10
+
11
+ ### Added
12
+
13
+ - Test against Ruby 3.0 in the CI build ([#67]).
14
+
15
+ ### Changed
16
+
17
+ - Use GitHub Actions for the CI build instead of Travis CI ([#66]).
18
+ - This project now uses `main` as its default branch ([#68]).
19
+ - Documentation updated to refer to `main` and links updated accordingly.
20
+
21
+ ### Removed
22
+ - Remove Ruby 2.3, 2.4 and 2.5 from the CI test matrix ([#70]).
23
+
24
+ [#66]: https://github.com/envato/event_sourcery-postgres/pull/66
25
+ [#67]: https://github.com/envato/event_sourcery-postgres/pull/67
26
+ [#68]: https://github.com/envato/event_sourcery-postgres/pull/68
27
+ [#70]: https://github.com/envato/event_sourcery-postgres/pull/70
28
+
29
+ ## [0.8.1] - 2020-10-02
30
+ ### Added
31
+ - Add Ruby 2.6 and 2.7 to the CI test matrix.
32
+
33
+ ### Removed
34
+ - Remove Ruby 2.2 from the CI test matrix.
35
+ - Support for Boxen.
36
+
37
+ ### Fixed
38
+ - Upgrade development dependency Rake to version 13. This resolves
39
+ [CVE-2020-8130](https://github.com/advisories/GHSA-jppv-gw3r-w3q8).
40
+
41
+ - Resolve warnings raised when running on Ruby 2.7.
42
+
43
+ ## [0.8.0] - 2018-08-06
44
+ ### Added
45
+ - Add a `on_events_recorded` config option, that defaults to a no-op proc, \
46
+ to handle any app specific logic after the events are recoded on `EventStore#sink`
47
+
48
+ ## [0.7.0] - 2018-05-23
49
+ ### Added
50
+ - Add a `projector_transaction_size` config option to control how many events
51
+ are processed before the transaction is commited. The default value is 1 to
52
+ match the existing behavour.
53
+
54
+ We suggest setting this to match the number of events returned from the event
55
+ store subscription. This is [now configurable](https://github.com/envato/event_sourcery/pull/197)
56
+ in event_sourcery by configuring `subscription_batch_size`.
57
+
58
+ ### Removed
59
+ - Remove upper bound version restriction on `sequel` gem. Now accepts versions
60
+ 5 and higher.
61
+
62
+ ## [0.6.0] - 2018-01-02
8
63
  ### Changed
9
64
 
10
65
  - Only send info log after processing a group of events
@@ -13,11 +68,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
13
68
  - Remove `processes_events` and `projects_events` as these have been [removed
14
69
  in event_sourcery](https://github.com/envato/event_sourcery/pull/161).
15
70
 
16
- ## [0.5.0] - 2017-7-27
71
+ ## [0.5.0] - 2017-07-27
17
72
  - First Version of YARD documentation.
18
73
  - Fix Sequel deprecation by globally loading pg extensions
19
74
 
20
- ## [0.4.0] - 2017-6-21
75
+ ## [0.4.0] - 2017-06-21
21
76
  ### Changed
22
77
  - Reactors store the UUID of the event being processed in the `causation_id`
23
78
  of any emitted events. This replaces the old behaviour of storing id of the
@@ -30,7 +85,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
30
85
  - Added index on the `events` table for `correlation_id` and `causation_id`
31
86
  columns.
32
87
 
33
- ## [0.3.0] - 2017-6-16
88
+ ## [0.3.0] - 2017-06-16
34
89
  ### Changed
35
90
  - The event store persists the event `correlation_id` and `causation_id`.
36
91
  To facilitate this `correlation_id` and `causation_id` columns have been
@@ -40,7 +95,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
40
95
  - The emit_events method now accepts typed events instead of symbols
41
96
  - Remove dynamic emit events methods from reactors (e.g. emit_item_added)
42
97
 
43
- ## [0.2.0] - 2017-6-1
98
+ ## [0.2.0] - 2017-06-01
44
99
  ### Changed
45
100
  - Make `EventSourcery::Postgres::OptimisedEventPollWaiter#shutdown` private
46
101
  - Updated `EventSourcery::Postgres::OptimisedEventPollWaiter#poll` to ensure that `#shutdown!` is run when an error is raised
@@ -49,8 +104,19 @@ or when the loop stops
49
104
  ### Added
50
105
  - Configure projector tracker table name via `EventSourcery::Postgres.configure`
51
106
 
52
- ## [0.1.0] - 2017-5-26
107
+ ## 0.1.0 - 2017-05-26
53
108
  ### Changed
54
109
  - Imported code from the [event_sourcery](https://github.com/envato/event_sourcery).
55
110
  - Postgres related configuration is through `EventSourcery::Postgres.configure`
56
111
  instead of `EventSourcery.configure`.
112
+
113
+ [Unreleased]: https://github.com/envato/event_sourcery-postgres/compare/v0.9.0...HEAD
114
+ [0.9.0]: https://github.com/envato/event_sourcery-postgres/compare/v0.8.1...v0.9.0
115
+ [0.8.1]: https://github.com/envato/event_sourcery-postgres/compare/v0.8.0...v0.8.1
116
+ [0.8.0]: https://github.com/envato/event_sourcery-postgres/compare/v0.7.0...v0.8.0
117
+ [0.7.0]: https://github.com/envato/event_sourcery-postgres/compare/v0.6.0...v0.7.0
118
+ [0.6.0]: https://github.com/envato/event_sourcery-postgres/compare/v0.5.0...v0.6.0
119
+ [0.5.0]: https://github.com/envato/event_sourcery-postgres/compare/v0.4.0...v0.5.0
120
+ [0.4.0]: https://github.com/envato/event_sourcery-postgres/compare/v0.3.0...v0.4.0
121
+ [0.3.0]: https://github.com/envato/event_sourcery-postgres/compare/v0.2.0...v0.3.0
122
+ [0.2.0]: https://github.com/envato/event_sourcery-postgres/compare/v0.1.0...v0.2.0
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # EventSourcery::Postgres
2
2
 
3
- [![Build Status](https://travis-ci.org/envato/event_sourcery-postgres.svg?branch=master)](https://travis-ci.org/envato/event_sourcery-postgres)
3
+ [![Build Status](https://github.com/envato/event_sourcery-postgres/workflows/tests/badge.svg?branch=main)](https://github.com/envato/event_sourcery-postgres/actions?query=workflow%3Atests+branch%3Amain)
4
4
 
5
5
  ## Development Status
6
6
 
@@ -89,7 +89,7 @@ To install this gem onto your local machine, run `bundle exec rake install`.
89
89
  To release a new version:
90
90
 
91
91
  1. Update the version number in `lib/event_sourcery/postgres/version.rb`
92
- 2. Get this change onto master via the normal PR process
92
+ 2. Get this change onto main via the normal PR process
93
93
  3. Run `bundle exec rake release`, this will create a git tag for the
94
94
  version, push tags up to GitHub, and upload the gem to rubygems.org.
95
95
 
@@ -12,6 +12,11 @@ Gem::Specification.new do |spec|
12
12
 
13
13
  spec.summary = 'Postgres event store for use with EventSourcery'
14
14
  spec.homepage = 'https://github.com/envato/event_sourcery-postgres'
15
+ spec.metadata = {
16
+ 'bug_tracker_uri' => 'https://github.com/envato/event_sourcery-postgres/issues',
17
+ 'changelog_uri' => 'https://github.com/envato/event_sourcery-postgres/blob/HEAD/CHANGELOG.md',
18
+ 'source_code_uri' => 'https://github.com/envato/event_sourcery-postgres',
19
+ }
15
20
 
16
21
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
22
  f.match(%r{^(\.|bin/|Gemfile|Rakefile|script/|spec/)})
@@ -22,11 +27,11 @@ Gem::Specification.new do |spec|
22
27
 
23
28
  spec.required_ruby_version = '>= 2.2.0'
24
29
 
25
- spec.add_dependency 'sequel', '~> 4.38'
30
+ spec.add_dependency 'sequel', '>= 4.38'
26
31
  spec.add_dependency 'pg'
27
32
  spec.add_dependency 'event_sourcery', '>= 0.14.0'
28
- spec.add_development_dependency 'bundler', '~> 1.10'
29
- spec.add_development_dependency 'rake', '~> 10.0'
33
+ spec.add_development_dependency 'bundler'
34
+ spec.add_development_dependency 'rake', '~> 13'
30
35
  spec.add_development_dependency 'rspec', '~> 3.0'
31
36
  spec.add_development_dependency 'pry'
32
37
  spec.add_development_dependency 'benchmark-ips'
@@ -8,7 +8,9 @@ module EventSourcery
8
8
  :tracker_table_name,
9
9
  :callback_interval_if_no_new_events,
10
10
  :auto_create_projector_tracker,
11
- :event_tracker
11
+ :event_tracker,
12
+ :projector_transaction_size,
13
+ :on_events_recorded
12
14
 
13
15
  attr_writer :event_store,
14
16
  :event_source,
@@ -26,6 +28,8 @@ module EventSourcery
26
28
  @callback_interval_if_no_new_events = 10
27
29
  @event_store_database = nil
28
30
  @auto_create_projector_tracker = true
31
+ @projector_transaction_size = 1
32
+ @on_events_recorded = ->(events) {}
29
33
  end
30
34
 
31
35
  def event_store
@@ -7,12 +7,14 @@ module EventSourcery
7
7
  events_table_name: EventSourcery::Postgres.config.events_table_name,
8
8
  lock_table: EventSourcery::Postgres.config.lock_table_to_guarantee_linear_sequence_id_growth,
9
9
  write_events_function_name: EventSourcery::Postgres.config.write_events_function_name,
10
- event_builder: EventSourcery.config.event_builder)
10
+ event_builder: EventSourcery.config.event_builder,
11
+ on_events_recorded: EventSourcery::Postgres.config.on_events_recorded)
11
12
  @db_connection = db_connection
12
13
  @events_table_name = events_table_name
13
14
  @write_events_function_name = write_events_function_name
14
15
  @lock_table = lock_table
15
16
  @event_builder = event_builder
17
+ @on_events_recorded = on_events_recorded
16
18
  end
17
19
 
18
20
  # Like water flowing into a sink eventually it will go down the drain
@@ -33,6 +35,7 @@ module EventSourcery
33
35
  sql = write_events_sql(aggregate_ids.first, events, expected_version)
34
36
  @db_connection.run(sql)
35
37
  log_events_saved(events)
38
+ on_events_recorded.call(events)
36
39
  true
37
40
  rescue Sequel::DatabaseError => e
38
41
  if e.message =~ /Concurrency conflict/
@@ -57,7 +60,7 @@ module EventSourcery
57
60
  where(Sequel.lit('id >= ?', id)).
58
61
  limit(limit)
59
62
  query = query.where(type: event_types) if event_types
60
- query.map { |event_row| build_event(event_row) }
63
+ query.map { |event_row| build_event(**event_row) }
61
64
  end
62
65
 
63
66
  # Get last event id for a given event types.
@@ -83,7 +86,7 @@ module EventSourcery
83
86
  # @return [Array] of found events
84
87
  def get_events_for_aggregate_id(aggregate_id)
85
88
  events_table.where(aggregate_id: aggregate_id.to_str).order(:version).map do |event_hash|
86
- build_event(event_hash)
89
+ build_event(**event_hash)
87
90
  end
88
91
  end
89
92
 
@@ -104,17 +107,19 @@ module EventSourcery
104
107
  subscription_master: subscription_master,
105
108
  on_new_events: block
106
109
  }
107
- EventSourcery::EventStore::Subscription.new(args).tap(&:start)
110
+ EventSourcery::EventStore::Subscription.new(**args).tap(&:start)
108
111
  end
109
112
 
110
113
  private
111
114
 
115
+ attr_reader :on_events_recorded
116
+
112
117
  def events_table
113
118
  @db_connection[@events_table_name]
114
119
  end
115
120
 
116
- def build_event(data)
117
- @event_builder.build(data)
121
+ def build_event(**data)
122
+ @event_builder.build(**data)
118
123
  end
119
124
 
120
125
  def write_events_sql(aggregate_id, events, expected_version)
@@ -17,22 +17,30 @@ module EventSourcery
17
17
 
18
18
  module InstanceMethods
19
19
  def initialize(tracker: EventSourcery::Postgres.config.event_tracker,
20
- db_connection: EventSourcery::Postgres.config.projections_database)
20
+ db_connection: EventSourcery::Postgres.config.projections_database,
21
+ transaction_size: EventSourcery::Postgres.config.projector_transaction_size)
21
22
  @tracker = tracker
22
23
  @db_connection = db_connection
24
+ @transaction_size = transaction_size
23
25
  end
24
26
 
25
27
  private
26
28
 
29
+ attr_reader :transaction_size
30
+
27
31
  def process_events(events, subscription_master)
28
- events.each do |event|
32
+ events.each_slice(transaction_size) do |slice_of_events|
29
33
  subscription_master.shutdown_if_requested
34
+
30
35
  db_connection.transaction do
31
- process(event)
32
- tracker.processed_event(processor_name, event.id)
36
+ slice_of_events.each do |event|
37
+ process(event)
38
+ EventSourcery.logger.debug { "[#{processor_name}] Processed event: #{event.inspect}" }
39
+ end
40
+ tracker.processed_event(processor_name, slice_of_events.last.id)
33
41
  end
34
- EventSourcery.logger.debug { "[#{processor_name}] Processed event: #{event.inspect}" }
35
42
  end
43
+
36
44
  EventSourcery.logger.info { "[#{processor_name}] Processed up to event id: #{events.last.id}" }
37
45
  end
38
46
  end
@@ -53,7 +53,7 @@ module EventSourcery
53
53
  def create_aggregates(db: EventSourcery::Postgres.config.event_store_database,
54
54
  table_name: EventSourcery::Postgres.config.aggregates_table_name)
55
55
  db.create_table(table_name) do
56
- primary_key :aggregate_id, :uuid
56
+ uuid :aggregate_id, primary_key: true
57
57
  column :version, :bigint, default: 1
58
58
  end
59
59
  end
@@ -1,5 +1,5 @@
1
1
  module EventSourcery
2
2
  module Postgres
3
- VERSION = '0.6.0'.freeze
3
+ VERSION = '0.9.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: event_sourcery-postgres
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Envato
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-02 00:00:00.000000000 Z
11
+ date: 2021-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.38'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.38'
27
27
  - !ruby/object:Gem::Dependency
@@ -56,30 +56,30 @@ dependencies:
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '1.10'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '1.10'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '10.0'
75
+ version: '13'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '10.0'
82
+ version: '13'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -147,7 +147,10 @@ files:
147
147
  - lib/event_sourcery/postgres/version.rb
148
148
  homepage: https://github.com/envato/event_sourcery-postgres
149
149
  licenses: []
150
- metadata: {}
150
+ metadata:
151
+ bug_tracker_uri: https://github.com/envato/event_sourcery-postgres/issues
152
+ changelog_uri: https://github.com/envato/event_sourcery-postgres/blob/HEAD/CHANGELOG.md
153
+ source_code_uri: https://github.com/envato/event_sourcery-postgres
151
154
  post_install_message:
152
155
  rdoc_options: []
153
156
  require_paths:
@@ -163,8 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
166
  - !ruby/object:Gem::Version
164
167
  version: '0'
165
168
  requirements: []
166
- rubyforge_project:
167
- rubygems_version: 2.5.2
169
+ rubygems_version: 3.0.3
168
170
  signing_key:
169
171
  specification_version: 4
170
172
  summary: Postgres event store for use with EventSourcery