event_sourcery 0.15.0 → 0.16.1
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 +4 -4
- data/CHANGELOG.md +33 -1
- data/lib/event_sourcery/config.rb +1 -1
- data/lib/event_sourcery/errors.rb +1 -1
- data/lib/event_sourcery/event_processing/error_handlers/exponential_backoff_retry.rb +2 -0
- data/lib/event_sourcery/event_processing/event_stream_processor.rb +20 -32
- data/lib/event_sourcery/memory/config.rb +2 -4
- data/lib/event_sourcery/memory/projector.rb +0 -1
- data/lib/event_sourcery/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 851b272af6920686f8033e9d948e99281bd13886
|
4
|
+
data.tar.gz: 9f09be230953049d28e1e1686bb5a77f679105a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8653075d18913fc0bfdb3c69c607e28a47f71cf5dd76d1204fec159ae931c67343b67a3b12ff588385e79e3a06f2f1515c19e673623e2915e7bea4f079c32ca
|
7
|
+
data.tar.gz: 9f8562bb232db84fcf2d28973946385aacbbe98e712a396d2dd34cec0e7b0429943b530d6e5be3a671ed95b48c0920560055bcf3970281719d40907c41ff6a0d
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,5 @@
|
|
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/)
|
@@ -6,6 +7,25 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
7
|
|
7
8
|
## [Unreleased]
|
8
9
|
|
10
|
+
## [0.16.1] - 2018-01-17
|
11
|
+
- Fixed bug with Sequel gem expecting processes_event_types to be an Array
|
12
|
+
|
13
|
+
## [0.16.0] - 2018-01-02
|
14
|
+
### Added
|
15
|
+
- Added additional logging for retries to the ExponentialBackoffRetry error handler
|
16
|
+
- Remove `processes_events` and related methods in favour of `process` class
|
17
|
+
method. You can no longer override `process` and subscribe to all events.
|
18
|
+
If you want to subscribe to all events you can call the `process` class
|
19
|
+
method with no events.
|
20
|
+
|
21
|
+
process do |event|
|
22
|
+
# all events will be subscribed to
|
23
|
+
end
|
24
|
+
|
25
|
+
process Foobar do |event|
|
26
|
+
# Foobar events will be subscribed to
|
27
|
+
end
|
28
|
+
|
9
29
|
## [0.15.0] - 2017-11-29
|
10
30
|
### Added
|
11
31
|
- Added in the first version of the yard documentation.
|
@@ -50,7 +70,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
50
70
|
### Fixed
|
51
71
|
- Fixed: default poll waiter now implements `shutdown!`
|
52
72
|
|
53
|
-
## [0.11.
|
73
|
+
## [0.11.1] - 2017-5-29
|
54
74
|
### Fixed
|
55
75
|
- Use `processor.class.name` to set ESP process name
|
56
76
|
- Convert `processor_name` symbol to string explicitly
|
@@ -101,3 +121,15 @@ moving all Postgres related code into a separate gem.
|
|
101
121
|
### Removed
|
102
122
|
- EventSourcery no longer depends on Virtus.
|
103
123
|
- `Command` and `CommandHandler` have been removed.
|
124
|
+
|
125
|
+
[Unreleased]: https://github.com/envato/event_sourcery/compare/v0.16.0...HEAD
|
126
|
+
[0.16.0]: https://github.com/envato/event_sourcery/compare/v0.15.0...v0.16.0
|
127
|
+
[0.15.0]: https://github.com/envato/event_sourcery/compare/v0.14.0...v0.15.0
|
128
|
+
[0.14.0]: https://github.com/envato/event_sourcery/compare/v0.13.0...v0.14.0
|
129
|
+
[0.13.0]: https://github.com/envato/event_sourcery/compare/v0.12.0...v0.13.0
|
130
|
+
[0.12.0]: https://github.com/envato/event_sourcery/compare/v0.11.2...v0.12.0
|
131
|
+
[0.11.2]: https://github.com/envato/event_sourcery/compare/v0.11.1...v0.11.2
|
132
|
+
[0.11.1]: https://github.com/envato/event_sourcery/compare/v0.11.0...v0.11.1
|
133
|
+
[0.11.0]: https://github.com/envato/event_sourcery/compare/v0.10.0...v0.11.0
|
134
|
+
[0.10.0]: https://github.com/envato/event_sourcery/compare/v0.9.0...v0.10.0
|
135
|
+
[0.9.0]: https://github.com/envato/event_sourcery/compare/v0.8.0...v0.9.0
|
@@ -37,7 +37,7 @@ module EventSourcery
|
|
37
37
|
@on_event_processor_error = proc { |exception, processor_name|
|
38
38
|
# app specific custom logic ie. report to an error reporting service like Rollbar.
|
39
39
|
}
|
40
|
-
@
|
40
|
+
@event_builder = nil
|
41
41
|
@event_type_serializer = EventStore::EventTypeSerializers::Underscored.new
|
42
42
|
@error_handler_class = EventProcessing::ErrorHandlers::ConstantRetry
|
43
43
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module EventSourcery
|
2
2
|
Error = Class.new(StandardError)
|
3
3
|
UnableToLockProcessorError = Class.new(Error)
|
4
|
-
UnableToProcessEventError = Class.new(Error)
|
5
4
|
ConcurrencyError = Class.new(Error)
|
6
5
|
AtomicWriteToMultipleAggregatesNotSupported = Class.new(Error)
|
6
|
+
MultipleCatchAllHandlersDefined = Class.new(Error)
|
7
7
|
|
8
8
|
class EventProcessingError < Error
|
9
9
|
attr_reader :event, :processor
|
@@ -17,6 +17,7 @@ module EventSourcery
|
|
17
17
|
def initialize(processor_name:)
|
18
18
|
@processor_name = processor_name
|
19
19
|
@retry_interval = DEFAULT_RETRY_INTERVAL
|
20
|
+
@error_event_uuid = nil
|
20
21
|
end
|
21
22
|
|
22
23
|
# Will yield the block and attempt to retry in an exponential backoff.
|
@@ -26,6 +27,7 @@ module EventSourcery
|
|
26
27
|
report_error(error)
|
27
28
|
update_retry_interval(error)
|
28
29
|
sleep(@retry_interval)
|
30
|
+
EventSourcery.logger.info { "Retrying #{@processor_name} with error: #{error.message} at interval=#{@retry_interval}" }
|
29
31
|
retry
|
30
32
|
end
|
31
33
|
|
@@ -8,6 +8,7 @@ module EventSourcery
|
|
8
8
|
EventSourcery.event_stream_processor_registry.register(base)
|
9
9
|
base.class_eval do
|
10
10
|
@event_handlers = Hash.new { |hash, key| hash[key] = [] }
|
11
|
+
@all_event_handler = nil
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
@@ -21,22 +22,13 @@ module EventSourcery
|
|
21
22
|
# Handler that processes the given event.
|
22
23
|
#
|
23
24
|
# @raise [EventProcessingError] error raised due to processing isssues
|
24
|
-
# @raise [UnableToProcessEventError] raised if unable to process event type
|
25
25
|
#
|
26
26
|
# @param event [Event] the event to process
|
27
27
|
def process(event)
|
28
28
|
@_event = event
|
29
|
-
handlers = self.class.event_handlers[event.type]
|
30
|
-
|
31
|
-
|
32
|
-
instance_exec(event, &handler)
|
33
|
-
end
|
34
|
-
elsif self.class.processes?(event.type)
|
35
|
-
if defined?(super)
|
36
|
-
super(event)
|
37
|
-
else
|
38
|
-
raise UnableToProcessEventError, "I don't know how to process '#{event.type}' events."
|
39
|
-
end
|
29
|
+
handlers = (self.class.event_handlers[event.type] + [self.class.all_event_handler]).compact
|
30
|
+
handlers.each do |handler|
|
31
|
+
instance_exec(event, &handler)
|
40
32
|
end
|
41
33
|
@_event = nil
|
42
34
|
rescue
|
@@ -48,25 +40,10 @@ module EventSourcery
|
|
48
40
|
|
49
41
|
# @attr_reader processes_event_types [Array] Process Event Types
|
50
42
|
# @attr_reader event_handlers [Hash] Hash of handler blocks keyed by event
|
51
|
-
attr_reader
|
52
|
-
|
53
|
-
# Registers the event types to process.
|
54
|
-
#
|
55
|
-
# @param event_types a collection of event types to process
|
56
|
-
def processes_events(*event_types)
|
57
|
-
@processes_event_types = Array(@processes_event_types) | event_types.map(&:to_s)
|
58
|
-
end
|
59
|
-
|
60
|
-
# Indicate that this class can process all event types. Note that you need to call this method if you
|
61
|
-
# intend to process all event types, without calling {ProcessHandler#process} for each event type.
|
62
|
-
def processes_all_events
|
63
|
-
define_singleton_method :processes? do |_|
|
64
|
-
true
|
65
|
-
end
|
66
|
-
end
|
43
|
+
# @attr_reader all_event_handler [Proc] An event handler
|
44
|
+
attr_reader :processes_event_types, :event_handlers, :all_event_handler
|
67
45
|
|
68
46
|
# Can this class process this event type.
|
69
|
-
# If you use process_all_events this will always return true
|
70
47
|
#
|
71
48
|
# @param event_type the event type to check
|
72
49
|
#
|
@@ -90,12 +67,23 @@ module EventSourcery
|
|
90
67
|
|
91
68
|
# Process the events for the given event types with the given block.
|
92
69
|
#
|
70
|
+
# @raise [MultipleCatchAllHandlersDefined] error raised when attempting to define multiple catch all handlers.
|
71
|
+
#
|
93
72
|
# @param event_classes the event type classes to process
|
94
73
|
# @param block the code block used to process
|
95
74
|
def process(*event_classes, &block)
|
96
|
-
event_classes.
|
97
|
-
|
98
|
-
|
75
|
+
if event_classes.empty?
|
76
|
+
if @all_event_handler
|
77
|
+
raise MultipleCatchAllHandlersDefined, 'Attemping to define multiple catch all event handlers.'
|
78
|
+
else
|
79
|
+
@all_event_handler = block
|
80
|
+
end
|
81
|
+
else
|
82
|
+
@processes_event_types ||= []
|
83
|
+
event_classes.each do |event_class|
|
84
|
+
@processes_event_types << event_class.type
|
85
|
+
@event_handlers[event_class.type] << block
|
86
|
+
end
|
99
87
|
end
|
100
88
|
end
|
101
89
|
end
|
@@ -1,10 +1,8 @@
|
|
1
1
|
module EventSourcery
|
2
2
|
module Memory
|
3
3
|
class Config
|
4
|
-
attr_accessor :event_tracker
|
5
|
-
|
6
|
-
:event_source,
|
7
|
-
:event_sink
|
4
|
+
attr_accessor :event_tracker
|
5
|
+
attr_writer :event_store, :event_source, :event_sink
|
8
6
|
|
9
7
|
def initialize
|
10
8
|
@event_tracker = Memory::Tracker.new
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: event_sourcery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Envato
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
142
|
version: '0'
|
143
143
|
requirements: []
|
144
144
|
rubyforge_project:
|
145
|
-
rubygems_version: 2.
|
145
|
+
rubygems_version: 2.5.2
|
146
146
|
signing_key:
|
147
147
|
specification_version: 4
|
148
148
|
summary: Event Sourcing Library
|