event_sorcerer 0.1.1 → 0.1.2
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/event_sorcerer.gemspec +1 -0
- data/lib/event_sorcerer/aggregate.rb +4 -5
- data/lib/event_sorcerer/aggregate_loader.rb +0 -2
- data/lib/event_sorcerer/aggregate_proxy.rb +2 -2
- data/lib/event_sorcerer/event_store.rb +21 -19
- data/lib/event_sorcerer/message_bus.rb +5 -5
- data/lib/event_sorcerer/no_unit_of_work.rb +2 -2
- data/lib/event_sorcerer/unit_of_work.rb +2 -2
- data/lib/event_sorcerer/version.rb +1 -1
- data/lib/event_sorcerer.rb +2 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a30a15c744e7f3f861840bbdc3cfb822a5b8a88
|
4
|
+
data.tar.gz: 11012f39e7e59b80349a947f63216cec5f28657a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a2db2aaa933ed7280f7cebe9d6544bcd767a605ddc78108ed2e1911481d2efb5f7ebf2b364358b82e8777357a01190dab8e3bc11371db3b6f81844287e3c0a9
|
7
|
+
data.tar.gz: de9da895801ddd797276efdd48c55cccad6342a822eea80b6451a2e864f7b2c97bc59825c43f2387dc0137840639a65e1b31d2e92345f172a06949d2660b1d93
|
data/event_sorcerer.gemspec
CHANGED
@@ -13,9 +13,8 @@ module EventSorcerer
|
|
13
13
|
def self.included(base)
|
14
14
|
base.class.send :alias_method, :build, :new
|
15
15
|
base.extend(ClassMethods)
|
16
|
-
base.class.extend(
|
17
|
-
base.class.send :
|
18
|
-
:unit_of_work
|
16
|
+
base.class.extend(Uber::Delegates)
|
17
|
+
base.class.send :delegates, :EventSorcerer, :event_store, :unit_of_work
|
19
18
|
end
|
20
19
|
|
21
20
|
# Public: Class methods to be extended onto the including class.
|
@@ -111,7 +110,7 @@ module EventSorcerer
|
|
111
110
|
# block - the block to yield the event stream to.
|
112
111
|
#
|
113
112
|
# Returns the return value of the given block.
|
114
|
-
def with_all_event_streams_for_type
|
113
|
+
def with_all_event_streams_for_type
|
115
114
|
yield event_store.read_event_streams_for_type(name)
|
116
115
|
end
|
117
116
|
|
@@ -141,7 +140,7 @@ module EventSorcerer
|
|
141
140
|
#
|
142
141
|
# Returns the return value of the given block.
|
143
142
|
def with_event_stream_for_id(id)
|
144
|
-
yield event_store.read_event_stream(id)
|
143
|
+
yield event_store.read_event_stream(id, name)
|
145
144
|
end
|
146
145
|
|
147
146
|
# Private: Creates an AggregateLoader for an ID and yields it to a given
|
@@ -7,14 +7,14 @@ module EventSorcerer
|
|
7
7
|
# Public: Value object which is returned from a successful save.
|
8
8
|
class SaveReciept < Struct.new(:id, :klass, :events, :meta); end
|
9
9
|
|
10
|
-
extend
|
10
|
+
extend Uber::Delegates
|
11
11
|
|
12
12
|
instance_methods.each do |m|
|
13
13
|
undef_method(m) unless m =~ /(^__|^nil\?$|^send$|^object_id$|^tap$)/
|
14
14
|
end
|
15
15
|
|
16
16
|
# Public: Shortcuts to access the global event_store and unit_of_work.
|
17
|
-
|
17
|
+
delegates :EventSorcerer, :event_store, :unit_of_work
|
18
18
|
|
19
19
|
# Public: Creates a new AggregateProxy instance.
|
20
20
|
#
|
@@ -14,77 +14,79 @@ module EventSorcerer
|
|
14
14
|
# Public: Append events to a specified aggregate. Should be defined in a
|
15
15
|
# subclass.
|
16
16
|
#
|
17
|
-
#
|
18
|
-
#
|
17
|
+
# _id - UUID of the aggregate as a String.
|
18
|
+
# _type - Text representation of aggregate class.
|
19
19
|
# _events - Array of JSON-serialized events.
|
20
20
|
# _expected_version - The current version of the aggregate.
|
21
21
|
#
|
22
22
|
# Raises a NotImplementedError
|
23
|
-
def append_events(
|
23
|
+
def append_events(_id, _type, _events, _expected_version)
|
24
24
|
fail NotImplementedError
|
25
25
|
end
|
26
26
|
|
27
27
|
# Public: Retrieve the current version for a specified aggregate. Should
|
28
28
|
# be defined in a subclass.
|
29
29
|
#
|
30
|
-
#
|
30
|
+
# _id - UUID of the aggregate as a String.
|
31
31
|
#
|
32
32
|
# Raises a NotImplementedError
|
33
|
-
def get_current_version(
|
33
|
+
def get_current_version(_id, _type)
|
34
34
|
fail NotImplementedError
|
35
35
|
end
|
36
36
|
|
37
37
|
# Public: Retrieve the IDs for a given aggregate class. Should be defined
|
38
38
|
# in a subclass.
|
39
39
|
#
|
40
|
-
#
|
40
|
+
# _type - Text representation of aggregate class.
|
41
41
|
#
|
42
42
|
# Raises a NotImplementedError
|
43
|
-
def get_ids_for_type(
|
43
|
+
def get_ids_for_type(_type)
|
44
44
|
fail NotImplementedError
|
45
45
|
end
|
46
46
|
|
47
47
|
# Public: Retrieve the events for a specified aggregate. Should be defined
|
48
48
|
# in a subclass.
|
49
49
|
#
|
50
|
-
#
|
50
|
+
# _id - UUID of the aggregate as a String.
|
51
|
+
# _type - Text representation of aggregate class.
|
51
52
|
#
|
52
53
|
# Raises a NotImplementedError
|
53
|
-
def read_events(
|
54
|
+
def read_events(_id, _type)
|
54
55
|
fail NotImplementedError
|
55
56
|
end
|
56
57
|
|
57
58
|
# Public: Retrieve the event stream for a specified aggregate. Should be
|
58
59
|
# defined in a subclass.
|
59
60
|
#
|
60
|
-
#
|
61
|
+
# id - UUID of the aggregate as a String.
|
62
|
+
# type - Text representation of aggregate class.
|
61
63
|
#
|
62
64
|
# Returns an EventStream
|
63
|
-
def read_event_stream(
|
64
|
-
EventStream.new
|
65
|
-
get_current_version(aggregate_id))
|
65
|
+
def read_event_stream(id, type)
|
66
|
+
EventStream.new id, read_events(id, type), get_current_version(id, type)
|
66
67
|
end
|
67
68
|
|
68
69
|
# Public: Retrieve the event stream for all aggregates of a given type.
|
69
70
|
# Optionally can be defined in subclass to optimize loading these
|
70
71
|
# aggregates with a minimum of external calls.
|
71
72
|
#
|
72
|
-
#
|
73
|
+
# type - Text representation of aggregate class.
|
73
74
|
#
|
74
75
|
# Returns an Array.
|
75
|
-
def read_event_streams_for_type(
|
76
|
-
read_multiple_event_streams get_ids_for_type(
|
76
|
+
def read_event_streams_for_type(type)
|
77
|
+
read_multiple_event_streams get_ids_for_type(type), type
|
77
78
|
end
|
78
79
|
|
79
80
|
# Public: Retrieve the events for multiple aggregates. Optionally can be
|
80
81
|
# defined in subclass to optimize loading multiple aggregates with
|
81
82
|
# a minimum of external calls.
|
82
83
|
#
|
83
|
-
#
|
84
|
+
# ids - Array of UUIDs of the aggregates as Strings.
|
85
|
+
# type - Text representation of aggregate class.
|
84
86
|
#
|
85
87
|
# Returns an Array.
|
86
|
-
def read_multiple_event_streams(
|
87
|
-
|
88
|
+
def read_multiple_event_streams(ids, type)
|
89
|
+
ids.map { |id| read_event_stream id, type }
|
88
90
|
end
|
89
91
|
|
90
92
|
# Public: Ensures events appended within the given block are done so
|
@@ -4,13 +4,13 @@ module EventSorcerer
|
|
4
4
|
# Public: Publish events for a specified aggregate. Should be defined in a
|
5
5
|
# subclass.
|
6
6
|
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
# _events
|
10
|
-
# _meta
|
7
|
+
# _id - UUID of the aggregate as a String.
|
8
|
+
# _type - Text representation of aggregate class.
|
9
|
+
# _events - Array of Event objects.
|
10
|
+
# _meta - Hash of extra data to publish on the bus.
|
11
11
|
#
|
12
12
|
# Raises a NotImplementedError
|
13
|
-
def publish_events(
|
13
|
+
def publish_events(_id, _type, _events, _meta)
|
14
14
|
fail NotImplementedError
|
15
15
|
end
|
16
16
|
end
|
@@ -2,10 +2,10 @@ module EventSorcerer
|
|
2
2
|
# Public: Handles the API of a UnitOfWork but does nothing.
|
3
3
|
module NoUnitOfWork
|
4
4
|
class << self
|
5
|
-
extend
|
5
|
+
extend Uber::Delegates
|
6
6
|
|
7
7
|
# Public: Shortcuts to access the global message_bus.
|
8
|
-
|
8
|
+
delegates :EventSorcerer, :message_bus
|
9
9
|
|
10
10
|
# Public: Returns nil.
|
11
11
|
def fetch_aggregate(_id)
|
@@ -2,10 +2,10 @@ module EventSorcerer
|
|
2
2
|
# Public: Provides transactional integrity across multiple aggregate saves.
|
3
3
|
# Also provides an indentity map.
|
4
4
|
class UnitOfWork
|
5
|
-
extend
|
5
|
+
extend Uber::Delegates
|
6
6
|
|
7
7
|
# Public: Shortcuts to access the global event_store and message_bus.
|
8
|
-
|
8
|
+
delegates :EventSorcerer, :event_store, :message_bus
|
9
9
|
|
10
10
|
# Public: Creates a new UnitOfWork instance.
|
11
11
|
def initialize
|
data/lib/event_sorcerer.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: event_sorcerer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Edwards
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 0.7.1
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: uber
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.0.11
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.0.11
|
111
125
|
description: '["Generic", "event-sourcing", "scaffold"]'
|
112
126
|
email:
|
113
127
|
- me@sebastianedwards.co.nz
|