synapse-core 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/synapse/auditing/audit_logger.rb +8 -4
- data/lib/synapse/auditing/correlation_data_provider.rb +4 -1
- data/lib/synapse/auditing/data_provider.rb +3 -1
- data/lib/synapse/command/command_bus.rb +14 -6
- data/lib/synapse/command/command_filter.rb +5 -3
- data/lib/synapse/command/command_handler.rb +5 -3
- data/lib/synapse/command/dispatch_interceptor.rb +5 -3
- data/lib/synapse/command/duplication.rb +3 -3
- data/lib/synapse/command/mapping.rb +1 -1
- data/lib/synapse/command/rollback_policy.rb +6 -4
- data/lib/synapse/domain/simple_stream.rb +2 -0
- data/lib/synapse/domain/stream.rb +10 -6
- data/lib/synapse/event_bus/clustering/cluster.rb +10 -0
- data/lib/synapse/event_bus/clustering/event_bus.rb +55 -0
- data/lib/synapse/event_bus/clustering/selector.rb +14 -0
- data/lib/synapse/event_bus/event_bus.rb +9 -3
- data/lib/synapse/event_bus/event_listener.rb +5 -3
- data/lib/synapse/event_bus/mapping.rb +7 -4
- data/lib/synapse/event_sourcing/aggregate_factory.rb +6 -2
- data/lib/synapse/event_sourcing/conflict_resolver.rb +11 -0
- data/lib/synapse/event_sourcing/member.rb +1 -1
- data/lib/synapse/event_sourcing/snapshot/policy.rb +3 -1
- data/lib/synapse/event_sourcing/snapshot/taker.rb +3 -1
- data/lib/synapse/event_store/event_store.rb +12 -6
- data/lib/synapse/event_store/in_memory.rb +2 -2
- data/lib/synapse/mapping/mapping.rb +8 -2
- data/lib/synapse/process_manager/correlation.rb +2 -2
- data/lib/synapse/process_manager/correlation_resolver.rb +5 -3
- data/lib/synapse/process_manager/mapping/process.rb +4 -5
- data/lib/synapse/process_manager/pessimistic_lock_manager.rb +2 -2
- data/lib/synapse/process_manager/process.rb +3 -1
- data/lib/synapse/process_manager/process_factory.rb +6 -2
- data/lib/synapse/process_manager/process_manager.rb +6 -2
- data/lib/synapse/process_manager/process_repository.rb +14 -6
- data/lib/synapse/repository/lock_manager.rb +17 -3
- data/lib/synapse/repository/locking.rb +3 -1
- data/lib/synapse/repository/repository.rb +15 -5
- data/lib/synapse/serialization/converter.rb +3 -1
- data/lib/synapse/serialization/message/serialization_aware.rb +6 -2
- data/lib/synapse/serialization/revision_resolver.rb +3 -1
- data/lib/synapse/serialization/serializer.rb +9 -3
- data/lib/synapse/uow/nesting.rb +18 -6
- data/lib/synapse/uow/transaction_manager.rb +11 -5
- data/lib/synapse/upcasting/single_upcaster.rb +15 -16
- data/lib/synapse/upcasting/upcaster.rb +20 -17
- data/lib/synapse/upcasting/upcaster_chain.rb +2 -2
- data/lib/synapse/version.rb +1 -1
- data/test/auditing/data_provider_test.rb +9 -1
- data/test/command/mapping_test.rb +8 -2
- data/test/event_bus/mapping_test.rb +7 -2
- data/test/event_sourcing/repository_test.rb +1 -1
- data/test/repository/locking_test.rb +3 -0
- data/test/upcasting/fixtures.rb +3 -8
- metadata +5 -2
@@ -12,7 +12,9 @@ module Synapse
|
|
12
12
|
# @param [Class] type
|
13
13
|
# @param [Correlation] correlation
|
14
14
|
# @return [Set]
|
15
|
-
def find(type, correlation)
|
15
|
+
def find(type, correlation)
|
16
|
+
raise NotImplementedError
|
17
|
+
end
|
16
18
|
|
17
19
|
# Loads a known process by its unique identifier
|
18
20
|
#
|
@@ -25,7 +27,9 @@ module Synapse
|
|
25
27
|
# @abstract
|
26
28
|
# @param [String] id
|
27
29
|
# @return [Process] Returns nil if process could not be found
|
28
|
-
def load(id)
|
30
|
+
def load(id)
|
31
|
+
raise NotImplementedError
|
32
|
+
end
|
29
33
|
|
30
34
|
# Commits the changes made to the process instance
|
31
35
|
#
|
@@ -35,7 +39,9 @@ module Synapse
|
|
35
39
|
# @abstract
|
36
40
|
# @param [Process] process
|
37
41
|
# @return [undefined]
|
38
|
-
def commit(process)
|
42
|
+
def commit(process)
|
43
|
+
raise NotImplementedError
|
44
|
+
end
|
39
45
|
|
40
46
|
# Registers a newly created process with the repository
|
41
47
|
#
|
@@ -47,7 +53,9 @@ module Synapse
|
|
47
53
|
# @abstract
|
48
54
|
# @param [Process] process
|
49
55
|
# @return [undefined]
|
50
|
-
def add(process)
|
51
|
-
|
52
|
-
|
56
|
+
def add(process)
|
57
|
+
raise NotImplementedError
|
58
|
+
end
|
59
|
+
end # ProcessRepository
|
60
|
+
end # ProcessManager
|
53
61
|
end
|
@@ -8,7 +8,9 @@ module Synapse
|
|
8
8
|
# @abstract
|
9
9
|
# @param [AggregateRoot] aggregate
|
10
10
|
# @return [Boolean]
|
11
|
-
def validate_lock(aggregate)
|
11
|
+
def validate_lock(aggregate)
|
12
|
+
raise NotImplementedError
|
13
|
+
end
|
12
14
|
|
13
15
|
# Obtains a lock for an aggregate with the given aggregate identifier. Depending on
|
14
16
|
# the strategy, this method may return immediately or block until a lock is held.
|
@@ -16,7 +18,9 @@ module Synapse
|
|
16
18
|
# @abstract
|
17
19
|
# @param [Object] aggregate_id
|
18
20
|
# @return [undefined]
|
19
|
-
def obtain_lock(aggregate_id)
|
21
|
+
def obtain_lock(aggregate_id)
|
22
|
+
raise NotImplementedError
|
23
|
+
end
|
20
24
|
|
21
25
|
# Releases the lock held for an aggregate with the given aggregate identifier. The caller
|
22
26
|
# of this method must ensure a valid lock was requested using {#obtain_lock}. If no lock
|
@@ -25,7 +29,9 @@ module Synapse
|
|
25
29
|
# @abstract
|
26
30
|
# @param [Object] aggregate_id
|
27
31
|
# @return [undefined]
|
28
|
-
def release_lock(aggregate_id)
|
32
|
+
def release_lock(aggregate_id)
|
33
|
+
raise NotImplementedError
|
34
|
+
end
|
29
35
|
end # LockManager
|
30
36
|
|
31
37
|
# Implementation of a lock manager that does no locking
|
@@ -35,6 +41,14 @@ module Synapse
|
|
35
41
|
def validate_lock(aggregate)
|
36
42
|
true
|
37
43
|
end
|
44
|
+
|
45
|
+
# @param [Object] aggregate_id
|
46
|
+
# @return [undefined]
|
47
|
+
def obtain_lock(aggregate_id); end
|
48
|
+
|
49
|
+
# @param [Object] aggregate_id
|
50
|
+
# @return [undefined]
|
51
|
+
def release_lock(aggregate_id); end
|
38
52
|
end # NullLockManager
|
39
53
|
end # Repository
|
40
54
|
end
|
@@ -70,7 +70,9 @@ module Synapse
|
|
70
70
|
# @param [Object] aggregate_id
|
71
71
|
# @param [Integer] expected_version
|
72
72
|
# @return [AggregateRoot]
|
73
|
-
def perform_load(aggregate_id, expected_version)
|
73
|
+
def perform_load(aggregate_id, expected_version)
|
74
|
+
raise NotImplementedError
|
75
|
+
end
|
74
76
|
|
75
77
|
# Hook that is called after an aggregate is registered to the current unit of work
|
76
78
|
#
|
@@ -26,7 +26,9 @@ module Synapse
|
|
26
26
|
# @param [Object] aggregate_id
|
27
27
|
# @param [Integer] expected_version If this is nil, no version validation is performed
|
28
28
|
# @return [AggregateRoot]
|
29
|
-
def load(aggregate_id, expected_version = nil)
|
29
|
+
def load(aggregate_id, expected_version = nil)
|
30
|
+
raise NotImplementedError
|
31
|
+
end
|
30
32
|
|
31
33
|
# Adds a new, unmanaged aggregate to the repository
|
32
34
|
#
|
@@ -38,7 +40,9 @@ module Synapse
|
|
38
40
|
# @raise [ArgumentError] If the version of the aggregate is not null
|
39
41
|
# @param [AggregateRoot] aggregate
|
40
42
|
# @return [undefined]
|
41
|
-
def add(aggregate)
|
43
|
+
def add(aggregate)
|
44
|
+
raise NotImplementedError
|
45
|
+
end
|
42
46
|
|
43
47
|
protected
|
44
48
|
|
@@ -46,21 +50,27 @@ module Synapse
|
|
46
50
|
#
|
47
51
|
# @abstract
|
48
52
|
# @return [Class]
|
49
|
-
def aggregate_type
|
53
|
+
def aggregate_type
|
54
|
+
raise NotImplementedError
|
55
|
+
end
|
50
56
|
|
51
57
|
# Deletes the given aggregate from the underlying storage mechanism
|
52
58
|
#
|
53
59
|
# @abstract
|
54
60
|
# @param [AggregateRoot] aggregate
|
55
61
|
# @return [undefined]
|
56
|
-
def delete_aggregate(aggregate)
|
62
|
+
def delete_aggregate(aggregate)
|
63
|
+
raise NotImplementedError
|
64
|
+
end
|
57
65
|
|
58
66
|
# Saves the given aggregate using the underlying storage mechanism
|
59
67
|
#
|
60
68
|
# @abstract
|
61
69
|
# @param [AggregateRoot] aggregate
|
62
70
|
# @return [undefined]
|
63
|
-
def save_aggregate(aggregate)
|
71
|
+
def save_aggregate(aggregate)
|
72
|
+
raise NotImplementedError
|
73
|
+
end
|
64
74
|
|
65
75
|
# Asserts that an aggregate being added is compatible with this repository and is newly
|
66
76
|
# created
|
@@ -6,12 +6,16 @@ module Synapse
|
|
6
6
|
# @param [Serializer] serializer
|
7
7
|
# @param [Class] expected_type
|
8
8
|
# @return [SerializedObject]
|
9
|
-
def serialize_metadata(serializer, expected_type)
|
9
|
+
def serialize_metadata(serializer, expected_type)
|
10
|
+
raise NotImplementedError
|
11
|
+
end
|
10
12
|
|
11
13
|
# @param [Serializer] serializer
|
12
14
|
# @param [Class] expected_type
|
13
15
|
# @return [SerializedObject]
|
14
|
-
def serialize_payload(serializer, expected_type)
|
16
|
+
def serialize_payload(serializer, expected_type)
|
17
|
+
raise NotImplementedError
|
18
|
+
end
|
15
19
|
end # SerializationAware
|
16
20
|
end # Serialization
|
17
21
|
end
|
@@ -8,7 +8,9 @@ module Synapse
|
|
8
8
|
# @abstract
|
9
9
|
# @param [Class] payload_type
|
10
10
|
# @return [String] The revision of the given payload type
|
11
|
-
def revision_of(payload_type)
|
11
|
+
def revision_of(payload_type)
|
12
|
+
raise NotImplementedError
|
13
|
+
end
|
12
14
|
end # RevisionResolver
|
13
15
|
|
14
16
|
# Implementation of a revision resolver that returns a fixed value. This could be an
|
@@ -68,7 +68,9 @@ module Synapse
|
|
68
68
|
# @abstract
|
69
69
|
# @param [Object] content The original Ruby object to serialize
|
70
70
|
# @return [Object] Should be in the native content type of the serializer
|
71
|
-
def perform_serialize(content)
|
71
|
+
def perform_serialize(content)
|
72
|
+
raise NotImplementedError
|
73
|
+
end
|
72
74
|
|
73
75
|
# Deserializes the given serialized content into the given Ruby type
|
74
76
|
#
|
@@ -76,13 +78,17 @@ module Synapse
|
|
76
78
|
# @param [Object] content Should be in the native content type of the serializer
|
77
79
|
# @param [Class] type The class type to be deserialized into
|
78
80
|
# @return [Object] The deserialized object
|
79
|
-
def perform_deserialize(content, type)
|
81
|
+
def perform_deserialize(content, type)
|
82
|
+
raise NotImplementedError
|
83
|
+
end
|
80
84
|
|
81
85
|
# Returns the native content type that the serializer works with
|
82
86
|
#
|
83
87
|
# @abstract
|
84
88
|
# @return [Class]
|
85
|
-
def native_content_type
|
89
|
+
def native_content_type
|
90
|
+
raise NotImplementedError
|
91
|
+
end
|
86
92
|
|
87
93
|
private
|
88
94
|
|
data/lib/synapse/uow/nesting.rb
CHANGED
@@ -121,38 +121,50 @@ module Synapse
|
|
121
121
|
#
|
122
122
|
# @abstract
|
123
123
|
# @return [undefined]
|
124
|
-
def perform_commit
|
124
|
+
def perform_commit
|
125
|
+
raise NotImplementedError
|
126
|
+
end
|
125
127
|
|
126
128
|
# Executes logic required to rollback this unit of work
|
127
129
|
#
|
128
130
|
# @abstract
|
129
131
|
# @param [Error] cause
|
130
132
|
# @return [undefined]
|
131
|
-
def perform_rollback(cause = nil)
|
133
|
+
def perform_rollback(cause = nil)
|
134
|
+
raise NotImplementedError
|
135
|
+
end
|
132
136
|
|
133
137
|
# Notifies listeners that this unit of work is cleaning up
|
134
138
|
#
|
135
139
|
# @abstract
|
136
140
|
# @return [undefined]
|
137
|
-
def notify_cleanup
|
141
|
+
def notify_cleanup
|
142
|
+
raise NotImplementedError
|
143
|
+
end
|
138
144
|
|
139
145
|
# Notifies listeners that this unit of work is preparing to be committed
|
140
146
|
#
|
141
147
|
# @abstract
|
142
148
|
# @return [undefined]
|
143
|
-
def notify_prepare_commit
|
149
|
+
def notify_prepare_commit
|
150
|
+
raise NotImplementedError
|
151
|
+
end
|
144
152
|
|
145
153
|
# Executes logic required when starting this unit of work
|
146
154
|
#
|
147
155
|
# @abstract
|
148
156
|
# @return [undefined]
|
149
|
-
def perform_start
|
157
|
+
def perform_start
|
158
|
+
raise NotImplementedError
|
159
|
+
end
|
150
160
|
|
151
161
|
# Storages aggregates registered with this unit of work
|
152
162
|
#
|
153
163
|
# @abstract
|
154
164
|
# @return [undefined]
|
155
|
-
def store_aggregates
|
165
|
+
def store_aggregates
|
166
|
+
raise NotImplementedError
|
167
|
+
end
|
156
168
|
|
157
169
|
# Commits all registered inner units of work. This should be invoked after events have been
|
158
170
|
# dispatched and before any listeners are notified of the commit.
|
@@ -9,19 +9,25 @@ module Synapse
|
|
9
9
|
#
|
10
10
|
# @abstract
|
11
11
|
# @return [Object]
|
12
|
-
def start
|
12
|
+
def start
|
13
|
+
raise NotImplementedError
|
14
|
+
end
|
13
15
|
|
14
16
|
# Commits the given transaction
|
15
17
|
#
|
16
18
|
# @param [Object] transaction
|
17
19
|
# @return [undefined]
|
18
|
-
def commit(transaction)
|
20
|
+
def commit(transaction)
|
21
|
+
raise NotImplementedError
|
22
|
+
end
|
19
23
|
|
20
24
|
# Rolls back the given transaction
|
21
25
|
#
|
22
26
|
# @param [Object] transaction
|
23
27
|
# @return [undefined]
|
24
|
-
def rollback(transaction)
|
25
|
-
|
26
|
-
|
28
|
+
def rollback(transaction)
|
29
|
+
raise NotImplementedError
|
30
|
+
end
|
31
|
+
end # TransactionManager
|
32
|
+
end # UnitOfWork
|
27
33
|
end
|
@@ -6,21 +6,18 @@ module Synapse
|
|
6
6
|
# This mixin is not suitable if an upcaster needs to upcast a serialized object into multiple
|
7
7
|
# newer serialized objects, or when the output representation type is not the same as the
|
8
8
|
# expected representation type.
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
#
|
10
|
+
# @abstract
|
11
|
+
class SingleUpcaster < Upcaster
|
13
12
|
# @param [SerialiedObject] intermediate
|
14
13
|
# @param [Array<SerializedType>] expected_types
|
15
14
|
# @param [UpcastingContext] upcast_context
|
16
15
|
# @return [Array<SerializedObject>]
|
17
16
|
def upcast(intermediate, expected_types, upcast_context)
|
18
|
-
upcast_content = perform_upcast
|
17
|
+
upcast_content = perform_upcast intermediate, upcast_context
|
19
18
|
upcast_objects = Array.new
|
20
19
|
|
21
|
-
unless upcast_content
|
22
|
-
return upcast_objects
|
23
|
-
end
|
20
|
+
return upcast_objects unless upcast_content
|
24
21
|
|
25
22
|
upcast_objects.push Serialization::SerializedObject.new(upcast_content, expected_content_type, expected_types.at(0))
|
26
23
|
upcast_objects
|
@@ -29,12 +26,10 @@ module Synapse
|
|
29
26
|
# @param [SerializedType] serialized_type
|
30
27
|
# @return [Array<SerializedType>]
|
31
28
|
def upcast_type(serialized_type)
|
32
|
-
upcast_type = perform_upcast_type
|
29
|
+
upcast_type = perform_upcast_type serialized_type
|
33
30
|
upcast_types = Array.new
|
34
31
|
|
35
|
-
unless upcast_type
|
36
|
-
return upcast_types
|
37
|
-
end
|
32
|
+
return upcast_types unless upcast_type
|
38
33
|
|
39
34
|
upcast_types.push upcast_type
|
40
35
|
upcast_types
|
@@ -46,12 +41,16 @@ module Synapse
|
|
46
41
|
# @param [SerializedObject] intermediate
|
47
42
|
# @param [UpcastingContext] upcast_context
|
48
43
|
# @return [Object] If nil is returned, the serialized object will be dropped
|
49
|
-
def perform_upcast(intermediate, upcast_context)
|
44
|
+
def perform_upcast(intermediate, upcast_context)
|
45
|
+
raise NotImplementedError
|
46
|
+
end
|
50
47
|
|
51
48
|
# @abstract
|
52
49
|
# @param [SerializedType] serialized_type
|
53
50
|
# @return [SerializedType] If nil is returned, the serialized object will be dropped
|
54
|
-
def perform_upcast_type(serialized_type)
|
55
|
-
|
56
|
-
|
51
|
+
def perform_upcast_type(serialized_type)
|
52
|
+
raise NotImplementedError
|
53
|
+
end
|
54
|
+
end # SingleUpcaster
|
55
|
+
end # Upcasting
|
57
56
|
end
|
@@ -10,19 +10,16 @@ module Synapse
|
|
10
10
|
#
|
11
11
|
# For performance reasons, it is advisable to ensure that all upcasters in the same chain use
|
12
12
|
# the same intermediate representation type.
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
13
|
+
#
|
14
|
+
# @abstract
|
15
|
+
class Upcaster
|
16
|
+
# @return [Class]
|
17
|
+
class_attribute :expected_content_type
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
self.expected_content_type = type
|
25
|
-
end
|
19
|
+
# @param [Class] type
|
20
|
+
# @return [undefined]
|
21
|
+
def self.expects_content_type(type)
|
22
|
+
self.expected_content_type = type
|
26
23
|
end
|
27
24
|
|
28
25
|
# Returns true if this upcaster is capable of upcasting the given type
|
@@ -30,7 +27,9 @@ module Synapse
|
|
30
27
|
# @abstract
|
31
28
|
# @param [SerializedType] serialized_type
|
32
29
|
# @return [Boolean]
|
33
|
-
def can_upcast?(serialized_type)
|
30
|
+
def can_upcast?(serialized_type)
|
31
|
+
raise NotImplementedError
|
32
|
+
end
|
34
33
|
|
35
34
|
# Upcasts a given serialized object to zero or more upcast objects
|
36
35
|
#
|
@@ -42,14 +41,18 @@ module Synapse
|
|
42
41
|
# @param [Array<SerializedType>] expected_types
|
43
42
|
# @param [UpcastingContext] upcast_context
|
44
43
|
# @return [Array<SerializedObject>]
|
45
|
-
def upcast(intermediate, expected_types, upcast_context)
|
44
|
+
def upcast(intermediate, expected_types, upcast_context)
|
45
|
+
raise NotImplementedError
|
46
|
+
end
|
46
47
|
|
47
48
|
# Upcasts a given serialized type to zero or more upcast types
|
48
49
|
#
|
49
50
|
# @abstract
|
50
51
|
# @param [SerializedType] serialized_type
|
51
52
|
# @return [Array<SerializedType>]
|
52
|
-
def upcast_type(serialized_type)
|
53
|
-
|
54
|
-
|
53
|
+
def upcast_type(serialized_type)
|
54
|
+
raise NotImplementedError
|
55
|
+
end
|
56
|
+
end # Upcaster
|
57
|
+
end # Upcasting
|
55
58
|
end
|
@@ -32,7 +32,7 @@ module Synapse
|
|
32
32
|
serialized_objects.push serialized_object
|
33
33
|
|
34
34
|
@upcasters.each do |upcaster|
|
35
|
-
serialized_objects = upcast_objects
|
35
|
+
serialized_objects = upcast_objects upcaster, serialized_objects, upcast_context
|
36
36
|
end
|
37
37
|
|
38
38
|
serialized_objects
|
@@ -46,7 +46,7 @@ module Synapse
|
|
46
46
|
# @param [UpcastingContent] upcast_context
|
47
47
|
# @return [Array<SerializedObject>]
|
48
48
|
def perform_upcast(upcaster, representation, expected_types, upcast_context)
|
49
|
-
upcaster.upcast
|
49
|
+
upcaster.upcast representation, expected_types, upcast_context
|
50
50
|
end
|
51
51
|
|
52
52
|
private
|
data/lib/synapse/version.rb
CHANGED
@@ -18,12 +18,20 @@ module Synapse
|
|
18
18
|
|
19
19
|
class CorrelationDataProviderTest < Test::Unit::TestCase
|
20
20
|
should 'provide the identifier of a command for auditing' do
|
21
|
-
provider = CorrelationDataProvider.new
|
21
|
+
provider = CorrelationDataProvider.new
|
22
22
|
command = Command::CommandMessage.build
|
23
23
|
|
24
24
|
expected = { :command_id => command.id }
|
25
25
|
assert_equal expected, provider.provide_data_for(command)
|
26
26
|
end
|
27
|
+
|
28
|
+
should 'provide the identifier of a command for auditing using an alternate key' do
|
29
|
+
provider = CorrelationDataProvider.new :correlation_id
|
30
|
+
command = Command::CommandMessage.build
|
31
|
+
|
32
|
+
expected = { :correlation_id => command.id }
|
33
|
+
assert_equal expected, provider.provide_data_for(command)
|
34
|
+
end
|
27
35
|
end
|
28
36
|
|
29
37
|
end
|
@@ -60,11 +60,17 @@ module Synapse
|
|
60
60
|
|
61
61
|
attr_accessor :handled, :sub_handled
|
62
62
|
|
63
|
-
map_command TestCommand do |command|
|
63
|
+
map_command TestCommand do |command, message, current_unit|
|
64
|
+
raise ArgumentError unless TestCommand === command
|
65
|
+
raise ArgumentError unless CommandMessage === message
|
66
|
+
raise ArgumentError if current_unit.nil?
|
67
|
+
|
64
68
|
@handled = true
|
65
69
|
end
|
66
70
|
|
67
|
-
map_command TestSubCommand
|
71
|
+
map_command TestSubCommand, :to => :on_sub
|
72
|
+
|
73
|
+
def on_sub(command)
|
68
74
|
@sub_handled = true
|
69
75
|
end
|
70
76
|
end
|
@@ -33,11 +33,16 @@ module Synapse
|
|
33
33
|
|
34
34
|
attr_accessor :handled, :sub_handled
|
35
35
|
|
36
|
-
map_event TestEvent do |event|
|
36
|
+
map_event TestEvent do |event, message|
|
37
|
+
raise ArgumentError unless TestEvent === event
|
38
|
+
raise ArgumentError unless Domain::EventMessage === message
|
39
|
+
|
37
40
|
@handled = true
|
38
41
|
end
|
39
42
|
|
40
|
-
map_event TestSubEvent
|
43
|
+
map_event TestSubEvent, :to => :on_sub
|
44
|
+
|
45
|
+
def on_sub(event)
|
41
46
|
@sub_handled = true
|
42
47
|
end
|
43
48
|
end
|
@@ -71,7 +71,7 @@ module Synapse
|
|
71
71
|
end
|
72
72
|
|
73
73
|
should 'defer version checking to a conflict resolver if one is set' do
|
74
|
-
@repository.conflict_resolver =
|
74
|
+
@repository.conflict_resolver = AcceptAllConflictResolver.new
|
75
75
|
|
76
76
|
event_a = create_event(123, 0, StubCreatedEvent.new(123))
|
77
77
|
event_b = create_event(123, 1, StubChangedEvent.new)
|
data/test/upcasting/fixtures.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module Synapse
|
2
2
|
module Upcasting
|
3
|
-
class TestSplitUpcaster
|
4
|
-
include Upcaster
|
3
|
+
class TestSplitUpcaster < Upcaster
|
5
4
|
|
6
5
|
expects_content_type Object
|
7
6
|
|
@@ -28,9 +27,7 @@ module Synapse
|
|
28
27
|
end
|
29
28
|
end
|
30
29
|
|
31
|
-
class TestTypeUpcaster
|
32
|
-
include SingleUpcaster
|
33
|
-
|
30
|
+
class TestTypeUpcaster < SingleUpcaster
|
34
31
|
expects_content_type Object
|
35
32
|
|
36
33
|
def can_upcast?(serialized_type)
|
@@ -48,9 +45,7 @@ module Synapse
|
|
48
45
|
end
|
49
46
|
end
|
50
47
|
|
51
|
-
class TestPhaseOutUpcaster
|
52
|
-
include SingleUpcaster
|
53
|
-
|
48
|
+
class TestPhaseOutUpcaster < SingleUpcaster
|
54
49
|
expects_content_type Object
|
55
50
|
|
56
51
|
def can_upcast?(serialized_type)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synapse-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -157,6 +157,9 @@ files:
|
|
157
157
|
- lib/synapse/domain/simple_stream.rb
|
158
158
|
- lib/synapse/domain/stream.rb
|
159
159
|
- lib/synapse/domain.rb
|
160
|
+
- lib/synapse/event_bus/clustering/cluster.rb
|
161
|
+
- lib/synapse/event_bus/clustering/event_bus.rb
|
162
|
+
- lib/synapse/event_bus/clustering/selector.rb
|
160
163
|
- lib/synapse/event_bus/event_bus.rb
|
161
164
|
- lib/synapse/event_bus/event_listener.rb
|
162
165
|
- lib/synapse/event_bus/event_publisher.rb
|