evt-messaging 2.5.1.1 → 2.5.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/messaging.rb +1 -0
- data/lib/messaging/controls.rb +1 -0
- data/lib/messaging/controls/handler.rb +20 -0
- data/lib/messaging/controls/metadata.rb +12 -4
- data/lib/messaging/controls/settings.rb +16 -0
- data/lib/messaging/handle.rb +19 -14
- data/lib/messaging/message/metadata.rb +79 -5
- data/lib/messaging/message/transform.rb +5 -0
- metadata +20 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba3a02132d665b05fe90598a8ff7a1678b2ca868fb4f47ade0fe80da9dadb793
|
4
|
+
data.tar.gz: fc424d43824775b2d672dcf1592bf3efe997f86453af341d05ceee3e56b3256e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12f6e4b7ecd4b166ea798052c648297e3b46b2a73b8c2dd5da940f37bbb4fca1f30eae8af0731bb1539841cd390a03ea04dc360aec46cfc6465a4f55ac0877b5
|
7
|
+
data.tar.gz: 638d0cce0872792272e9c444dc2c92534c57ab9db50523c3a4cdd104b00ef36dba8e39786f7448d09569c8a0bdb4b4a906abeab025e9a4691d2cc6429eecac65
|
data/lib/messaging.rb
CHANGED
data/lib/messaging/controls.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
module Messaging
|
2
2
|
module Controls
|
3
3
|
module Handler
|
4
|
+
def self.example
|
5
|
+
Example.new
|
6
|
+
end
|
7
|
+
|
4
8
|
class Example
|
5
9
|
include Messaging::Handle
|
6
10
|
include Controls::Message
|
@@ -97,6 +101,22 @@ module Messaging
|
|
97
101
|
end
|
98
102
|
end
|
99
103
|
end
|
104
|
+
|
105
|
+
module Settings
|
106
|
+
Error = Class.new(RuntimeError)
|
107
|
+
|
108
|
+
class Example
|
109
|
+
include Messaging::Handle
|
110
|
+
|
111
|
+
setting :some_setting
|
112
|
+
|
113
|
+
attr_accessor :some_other_setting
|
114
|
+
|
115
|
+
def handle(message_data)
|
116
|
+
raise Settings::Error if some_setting.nil?
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
100
120
|
end
|
101
121
|
end
|
102
122
|
end
|
@@ -13,6 +13,10 @@ module Messaging
|
|
13
13
|
1
|
14
14
|
end
|
15
15
|
|
16
|
+
def self.global_position
|
17
|
+
222
|
18
|
+
end
|
19
|
+
|
16
20
|
def self.causation_message_stream_name
|
17
21
|
"someCausation"
|
18
22
|
end
|
@@ -22,7 +26,7 @@ module Messaging
|
|
22
26
|
end
|
23
27
|
|
24
28
|
def self.causation_message_global_position
|
25
|
-
|
29
|
+
111
|
26
30
|
end
|
27
31
|
|
28
32
|
def self.correlation_stream_name
|
@@ -45,8 +49,10 @@ module Messaging
|
|
45
49
|
"#{causation_message_stream_name}/#{causation_message_position}"
|
46
50
|
end
|
47
51
|
|
48
|
-
def self.
|
49
|
-
|
52
|
+
def self.properties
|
53
|
+
{
|
54
|
+
some_property: 'some property value'
|
55
|
+
}
|
50
56
|
end
|
51
57
|
|
52
58
|
def self.time
|
@@ -57,6 +63,7 @@ module Messaging
|
|
57
63
|
{
|
58
64
|
stream_name: stream_name,
|
59
65
|
position: position,
|
66
|
+
global_position: global_position,
|
60
67
|
|
61
68
|
causation_message_stream_name: causation_message_stream_name,
|
62
69
|
causation_message_position: causation_message_position,
|
@@ -66,7 +73,8 @@ module Messaging
|
|
66
73
|
|
67
74
|
reply_stream_name: reply_stream_name,
|
68
75
|
|
69
|
-
|
76
|
+
properties: properties,
|
77
|
+
|
70
78
|
time: time,
|
71
79
|
|
72
80
|
schema_version: schema_version
|
data/lib/messaging/handle.rb
CHANGED
@@ -6,6 +6,7 @@ module Messaging
|
|
6
6
|
cls.class_exec do
|
7
7
|
include Dependency
|
8
8
|
include Virtual
|
9
|
+
include Settings::Setting
|
9
10
|
|
10
11
|
def handler_logger
|
11
12
|
@handler_logger ||= Log.get(self)
|
@@ -25,10 +26,14 @@ module Messaging
|
|
25
26
|
end
|
26
27
|
|
27
28
|
module Build
|
28
|
-
def build(strict: nil, session: nil)
|
29
|
+
def build(strict: nil, session: nil, settings: nil)
|
29
30
|
instance = new
|
30
31
|
instance.strict = strict
|
31
32
|
|
33
|
+
if not settings.nil?
|
34
|
+
settings.set(instance)
|
35
|
+
end
|
36
|
+
|
32
37
|
if Build.configure_session?(instance)
|
33
38
|
instance.configure(session: session)
|
34
39
|
else
|
@@ -60,8 +65,8 @@ module Messaging
|
|
60
65
|
end
|
61
66
|
|
62
67
|
module Call
|
63
|
-
def call(message_or_message_data, strict: nil, session: nil)
|
64
|
-
instance = build(strict: strict, session: session)
|
68
|
+
def call(message_or_message_data, strict: nil, session: nil, settings: nil)
|
69
|
+
instance = build(strict: strict, session: session, settings: settings)
|
65
70
|
instance.(message_or_message_data)
|
66
71
|
end
|
67
72
|
end
|
@@ -154,7 +159,7 @@ module Messaging
|
|
154
159
|
def handle_message(message, strict: nil)
|
155
160
|
strict ||= self.strict?
|
156
161
|
|
157
|
-
handler_logger.trace(tags: [:
|
162
|
+
handler_logger.trace(tags: [:dispatch, :message]) { "Dispatching message (Message class: #{message.class.name})" }
|
158
163
|
handler_logger.trace(tags: [:data, :message]) { message.pretty_inspect }
|
159
164
|
|
160
165
|
handler = self.class.handler(message)
|
@@ -162,8 +167,12 @@ module Messaging
|
|
162
167
|
unless handler.nil?
|
163
168
|
message_type = message.message_type
|
164
169
|
|
165
|
-
handler_logger.
|
170
|
+
handler_logger.trace(tag: [:handle, :message]) { "Handling Message (Type: #{message_type}, Method: #{handler})" }
|
171
|
+
|
166
172
|
public_send(handler, message)
|
173
|
+
|
174
|
+
handler_logger.info(tags: [:handle, :message]) { "Handled message (Message class: #{message.class.name})" }
|
175
|
+
handler_logger.info(tags: [:data, :message]) { message.pretty_inspect }
|
167
176
|
else
|
168
177
|
if strict
|
169
178
|
error_msg = "#{self.class.name} does not implement a handler for #{message.message_type}. Cannot handle the message."
|
@@ -172,16 +181,13 @@ module Messaging
|
|
172
181
|
end
|
173
182
|
end
|
174
183
|
|
175
|
-
handler_logger.info(tags: [:handle, :message]) { "Handled message (Message class: #{message.class.name})" }
|
176
|
-
handler_logger.info(tags: [:data, :message]) { message.pretty_inspect }
|
177
|
-
|
178
184
|
message
|
179
185
|
end
|
180
186
|
|
181
187
|
def handle_message_data(message_data, strict: nil)
|
182
188
|
strict ||= self.strict?
|
183
189
|
|
184
|
-
handler_logger.trace(tags: [:
|
190
|
+
handler_logger.trace(tags: [:dispatch, :message_data]) { "Dispatching message data (Type: #{message_data.type})" }
|
185
191
|
handler_logger.trace(tags: [:data, :message_data]) { message_data.pretty_inspect }
|
186
192
|
|
187
193
|
message = nil
|
@@ -203,15 +209,17 @@ module Messaging
|
|
203
209
|
|
204
210
|
message_type = message.message_type
|
205
211
|
|
206
|
-
handler_logger.debug(tag: :handle) { "Handling Message (Type: #{message_type}, Method: #{handler})" }
|
207
212
|
public_send(handler, message)
|
208
213
|
else
|
209
214
|
if respond_to?(:handle)
|
210
215
|
message_type = message_data.type
|
211
|
-
handler_logger.
|
216
|
+
handler_logger.trace(tag: [:handle, :message_data]) { "Handling Message Data (Type: #{message_type}, Method: handle" }
|
212
217
|
|
213
218
|
handle(message_data)
|
214
219
|
|
220
|
+
handler_logger.info(tags: [:handle, :message_data]) { "Handled message data (Type: #{message_data.type})" }
|
221
|
+
handler_logger.info(tags: [:data, :message_data]) { message_data.pretty_inspect }
|
222
|
+
|
215
223
|
message = message_data
|
216
224
|
else
|
217
225
|
if strict
|
@@ -222,9 +230,6 @@ module Messaging
|
|
222
230
|
end
|
223
231
|
end
|
224
232
|
|
225
|
-
handler_logger.info(tags: [:handle, :message_data]) { "Handled message data (Type: #{message_data.type})" }
|
226
|
-
handler_logger.info(tags: [:data, :message_data]) { message_data.pretty_inspect }
|
227
|
-
|
228
233
|
message
|
229
234
|
end
|
230
235
|
end
|
@@ -33,6 +33,8 @@ module Messaging
|
|
33
33
|
|
34
34
|
attribute :reply_stream_name, String
|
35
35
|
|
36
|
+
attribute :properties, Hash, default: -> { Hash.new }
|
37
|
+
|
36
38
|
attribute :time, Time
|
37
39
|
|
38
40
|
attribute :schema_version, String
|
@@ -59,11 +61,48 @@ module Messaging
|
|
59
61
|
self.reply_stream_name = preceding_metadata.reply_stream_name
|
60
62
|
end
|
61
63
|
|
62
|
-
def follows?(
|
63
|
-
causation_message_stream_name
|
64
|
-
|
65
|
-
|
66
|
-
|
64
|
+
def follows?(preceding_metadata)
|
65
|
+
if causation_message_stream_name.nil? && preceding_metadata.stream_name.nil?
|
66
|
+
return false
|
67
|
+
end
|
68
|
+
|
69
|
+
if causation_message_stream_name != preceding_metadata.stream_name
|
70
|
+
return false
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
if causation_message_position.nil? && preceding_metadata.position.nil?
|
75
|
+
return false
|
76
|
+
end
|
77
|
+
|
78
|
+
if causation_message_position != preceding_metadata.position
|
79
|
+
return false
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
if causation_message_global_position.nil? && preceding_metadata.global_position.nil?
|
84
|
+
return false
|
85
|
+
end
|
86
|
+
|
87
|
+
if causation_message_global_position != preceding_metadata.global_position
|
88
|
+
return false
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
if not preceding_metadata.correlation_stream_name.nil?
|
93
|
+
if correlation_stream_name != preceding_metadata.correlation_stream_name
|
94
|
+
return false
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
if not preceding_metadata.reply_stream_name.nil?
|
100
|
+
if reply_stream_name != preceding_metadata.reply_stream_name
|
101
|
+
return false
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
true
|
67
106
|
end
|
68
107
|
|
69
108
|
def clear_reply_stream_name
|
@@ -89,6 +128,41 @@ module Messaging
|
|
89
128
|
end
|
90
129
|
alias :correlates? :correlated?
|
91
130
|
|
131
|
+
def set_property(name, value)
|
132
|
+
properties[name] = value
|
133
|
+
end
|
134
|
+
|
135
|
+
def get_property(name)
|
136
|
+
properties[name]
|
137
|
+
end
|
138
|
+
|
139
|
+
def self.source_attribute_names
|
140
|
+
[
|
141
|
+
:stream_name,
|
142
|
+
:position,
|
143
|
+
:global_position
|
144
|
+
]
|
145
|
+
end
|
146
|
+
|
147
|
+
def self.causation_attribute_names
|
148
|
+
[
|
149
|
+
:causation_message_stream_name,
|
150
|
+
:causation_message_position,
|
151
|
+
:causation_message_global_position
|
152
|
+
]
|
153
|
+
end
|
154
|
+
|
155
|
+
def self.origin_attribute_names
|
156
|
+
[
|
157
|
+
:correlation_stream_name,
|
158
|
+
:reply_stream_name
|
159
|
+
]
|
160
|
+
end
|
161
|
+
|
162
|
+
def self.workflow_attribute_names
|
163
|
+
causation_attribute_names + origin_attribute_names
|
164
|
+
end
|
165
|
+
|
92
166
|
def self.transient_attributes
|
93
167
|
[
|
94
168
|
:stream_name,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evt-messaging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Eventide Project
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: evt-message_store
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: evt-settings
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: test_bench
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -54,6 +68,7 @@ files:
|
|
54
68
|
- lib/messaging/controls/message_data.rb
|
55
69
|
- lib/messaging/controls/metadata.rb
|
56
70
|
- lib/messaging/controls/random.rb
|
71
|
+
- lib/messaging/controls/settings.rb
|
57
72
|
- lib/messaging/controls/stream_name.rb
|
58
73
|
- lib/messaging/controls/time.rb
|
59
74
|
- lib/messaging/controls/write.rb
|
@@ -76,7 +91,7 @@ homepage: https://github.com/eventide-project/messaging
|
|
76
91
|
licenses:
|
77
92
|
- MIT
|
78
93
|
metadata: {}
|
79
|
-
post_install_message:
|
94
|
+
post_install_message:
|
80
95
|
rdoc_options: []
|
81
96
|
require_paths:
|
82
97
|
- lib
|
@@ -92,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
107
|
version: '0'
|
93
108
|
requirements: []
|
94
109
|
rubygems_version: 3.1.2
|
95
|
-
signing_key:
|
110
|
+
signing_key:
|
96
111
|
specification_version: 4
|
97
112
|
summary: Common primitives for platform-specific messaging implementations for Eventide
|
98
113
|
test_files: []
|