aggregate_streams 1.0.0.0.rc4 → 1.0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aggregate_streams.rb +1 -1
- data/lib/aggregate_streams/handle.rb +28 -28
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdcf7bac6c03a998987f6cf21d3e88efdf7bcef26f6d00c6e72f19363e1d58a3
|
4
|
+
data.tar.gz: d9cc11c444fd189ddc431009d5c32823144ed7f54b31285477c7ad67ce484791
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75b2874f85d2c020e81065d27923cac9b3b32c20805989ef84e381ed1399bddd427d06bef4a3c87e51feb9a51d040af39e0fcca6f9cef63f780307b8275af318
|
7
|
+
data.tar.gz: 687bbdb915c196352707e7d27fc633083ac86b28bd9c3964c6a3c71ce9c60f419848d9d15eb2af5754db661c0380c0a38a9e86a66f77e1e1c570c741708d5b4a
|
data/lib/aggregate_streams.rb
CHANGED
@@ -31,48 +31,48 @@ module AggregateStreams
|
|
31
31
|
def handle(message_data)
|
32
32
|
logger.trace { "Handling message (Stream: #{message_data.stream_name}, Global Position: #{message_data.global_position})" }
|
33
33
|
|
34
|
-
|
34
|
+
Retry.(MessageStore::ExpectedVersion::Error, millisecond_intervals: [0, 10, 100, 1000]) do
|
35
|
+
stream_id = Messaging::StreamName.get_id(message_data.stream_name)
|
35
36
|
|
36
|
-
|
37
|
+
aggregation, version = store.fetch(stream_id, include: :version)
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
if aggregation.processed?(message_data)
|
40
|
+
logger.info(tag: :ignored) { "Message already handled (Stream: #{message_data.stream_name}, Global Position: #{message_data.global_position})" }
|
41
|
+
return
|
42
|
+
end
|
42
43
|
|
43
|
-
|
44
|
-
|
44
|
+
raw_input_data = Messaging::Message::Transform::MessageData.read(message_data)
|
45
|
+
input_metadata = Messaging::Message::Metadata.build(raw_input_data[:metadata])
|
45
46
|
|
46
|
-
|
47
|
+
output_metadata = raw_metadata(input_metadata)
|
47
48
|
|
48
|
-
|
49
|
+
write_message_data = MessageStore::MessageData::Write.new
|
49
50
|
|
50
|
-
|
51
|
+
SetAttributes.(write_message_data, message_data, copy: [:type, :data])
|
51
52
|
|
52
|
-
|
53
|
+
write_message_data.metadata = output_metadata
|
53
54
|
|
54
|
-
|
55
|
-
|
55
|
+
input_category = Messaging::StreamName.get_category(message_data.stream_name)
|
56
|
+
write_message_data = transform(write_message_data, input_category)
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
if write_message_data
|
59
|
+
assure_message_data(write_message_data)
|
60
|
+
else
|
61
|
+
logger.info(tag: :ignored) { "Message ignored (Stream: #{message_data.stream_name}, Global Position: #{message_data.global_position})" }
|
62
|
+
return
|
63
|
+
end
|
63
64
|
|
64
|
-
Try.(MessageStore::ExpectedVersion::Error) do
|
65
65
|
stream_name = stream_name(stream_id)
|
66
66
|
write.(write_message_data, stream_name, expected_version: version)
|
67
|
-
end
|
68
67
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
68
|
+
logger.info do
|
69
|
+
message_type = message_data.type
|
70
|
+
unless write_message_data.type == message_type
|
71
|
+
message_type = "#{write_message_data.type} ← #{message_type}"
|
72
|
+
end
|
74
73
|
|
75
|
-
|
74
|
+
"Message copied (Message Type: #{message_type}, Stream: #{message_data.stream_name}, Global Position: #{message_data.global_position})"
|
75
|
+
end
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aggregate_streams
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.0
|
4
|
+
version: 1.0.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Ladd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: evt-consumer-postgres
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name: evt-
|
56
|
+
name: evt-retry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -132,11 +132,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
132
132
|
version: '2.7'
|
133
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
134
|
requirements:
|
135
|
-
- - "
|
135
|
+
- - ">="
|
136
136
|
- !ruby/object:Gem::Version
|
137
|
-
version:
|
137
|
+
version: '0'
|
138
138
|
requirements: []
|
139
|
-
rubygems_version: 3.
|
139
|
+
rubygems_version: 3.2.15
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: Combine messages from multiple Eventide streams into an aggregate stream
|