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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7bc5ad08d7cd5f55d19c1b407f80cd3448a6d877a22afd0f81b0261c25f2396c
4
- data.tar.gz: ba24610fc9a6e02666f4d5094ffb4bb13ab9c084f7fccc34f237fb9dc520cb4d
3
+ metadata.gz: ba3a02132d665b05fe90598a8ff7a1678b2ca868fb4f47ade0fe80da9dadb793
4
+ data.tar.gz: fc424d43824775b2d672dcf1592bf3efe997f86453af341d05ceee3e56b3256e
5
5
  SHA512:
6
- metadata.gz: 6a60193d1bd2f2bc8acb856b80dc76bf3bfb46ddb1a4d6810565b8725a1af6791e5197aaf94b1c89bc747af60b835c441e9a232d89acd97fe387d6cdc1e09352
7
- data.tar.gz: ada89ba5b187b8762be1c5b2da07040d40e8cb3f96d61d019020c0d8e2dc2755387de5040fb46f5ad45544a149fb3fdba99a7aabde039582b63f76ac11001c07
6
+ metadata.gz: 12f6e4b7ecd4b166ea798052c648297e3b46b2a73b8c2dd5da940f37bbb4fca1f30eae8af0731bb1539841cd390a03ea04dc360aec46cfc6465a4f55ac0877b5
7
+ data.tar.gz: 638d0cce0872792272e9c444dc2c92534c57ab9db50523c3a4cdd104b00ef36dba8e39786f7448d09569c8a0bdb4b4a906abeab025e9a4691d2cc6429eecac65
@@ -1,4 +1,5 @@
1
1
  require 'message_store'
2
+ require 'settings'
2
3
 
3
4
  require 'messaging/log'
4
5
 
@@ -12,4 +12,5 @@ require 'messaging/controls/message'
12
12
  require 'messaging/controls/metadata'
13
13
  require 'messaging/controls/batch'
14
14
  require 'messaging/controls/write'
15
+ require 'messaging/controls/settings'
15
16
  require 'messaging/controls/handler'
@@ -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
- 222
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.global_position
49
- 111
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
- global_position: global_position,
76
+ properties: properties,
77
+
70
78
  time: time,
71
79
 
72
80
  schema_version: schema_version
@@ -0,0 +1,16 @@
1
+ module Messaging
2
+ module Controls
3
+ module Settings
4
+ def self.example
5
+ ::Settings.build(data)
6
+ end
7
+
8
+ def self.data
9
+ {
10
+ some_setting: 'some setting value',
11
+ some_other_setting: 'some other setting value'
12
+ }
13
+ end
14
+ end
15
+ end
16
+ end
@@ -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: [:handle, :message]) { "Handling message (Message class: #{message.class.name})" }
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.debug(tag: :handle) { "Handling Message (Type: #{message_type}, Method: #{handler})" }
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: [:handle, :message_data]) { "Handling message data (Type: #{message_data.type})" }
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.debug(tag: :handle) { "Handling Message Data (Type: #{message_type}, Method: handle" }
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?(metadata)
63
- causation_message_stream_name == metadata.stream_name &&
64
- causation_message_position == metadata.position &&
65
- causation_message_global_position == metadata.global_position &&
66
- reply_stream_name == metadata.reply_stream_name
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,
@@ -25,6 +25,11 @@ module Messaging
25
25
  message_data.data = message.to_h
26
26
 
27
27
  metadata = message.metadata.to_h
28
+
29
+ if metadata[:properties].empty?
30
+ metadata[:properties] = nil
31
+ end
32
+
28
33
  metadata.delete_if { |k, v| v.nil? }
29
34
 
30
35
  message_data.metadata = metadata
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.1.1
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-07-20 00:00:00.000000000 Z
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: []