evt-messaging 2.5.5.0 → 2.5.8.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 +2 -1
- data/lib/messaging/controls/metadata.rb +8 -4
- data/lib/messaging/controls/properties.rb +62 -0
- data/lib/messaging/handle.rb +7 -0
- data/lib/messaging/message/copy.rb +7 -2
- data/lib/messaging/message/metadata.rb +34 -5
- data/lib/messaging/message/metadata/property.rb +22 -0
- data/lib/messaging/message/transform.rb +31 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed29a0c35879e58829f90553574808b36c4925450725c0e6b312e45cbb75abc7
|
4
|
+
data.tar.gz: 5c3649886b569d050834f02391672745595611a83a3a6fed8958070bab1ddaea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '04208a998e7aa313e679e41d064d8a8945b613dc6b2a3bea74cd2d53717cd69445d4824bd9c989ed42969798677f84bf756b1ed0989f385700d1e3dc3d467745'
|
7
|
+
data.tar.gz: a090214c089d0052e5a904b4e7c01b0537f4c7f5978e65766e89bf342c2c889294f438f3a07d59ef1c2f5f2381cfc0cfb715e0317a764c94763097fb7233a68f
|
data/lib/messaging.rb
CHANGED
@@ -7,6 +7,7 @@ require 'messaging/stream_name'
|
|
7
7
|
|
8
8
|
require 'messaging/message'
|
9
9
|
require 'messaging/message/metadata'
|
10
|
+
require 'messaging/message/metadata/property'
|
10
11
|
require 'messaging/message/copy'
|
11
12
|
require 'messaging/message/follow'
|
12
13
|
require 'messaging/message/sequence_accessor'
|
data/lib/messaging/controls.rb
CHANGED
@@ -7,9 +7,10 @@ require 'messaging/controls/random'
|
|
7
7
|
require 'messaging/controls/time'
|
8
8
|
require 'messaging/controls/id'
|
9
9
|
require 'messaging/controls/stream_name'
|
10
|
+
require 'messaging/controls/properties'
|
11
|
+
require 'messaging/controls/metadata'
|
10
12
|
require 'messaging/controls/message_data'
|
11
13
|
require 'messaging/controls/message'
|
12
|
-
require 'messaging/controls/metadata'
|
13
14
|
require 'messaging/controls/batch'
|
14
15
|
require 'messaging/controls/write'
|
15
16
|
require 'messaging/controls/settings'
|
@@ -2,6 +2,12 @@ module Messaging
|
|
2
2
|
module Controls
|
3
3
|
module Metadata
|
4
4
|
def self.example
|
5
|
+
data = self.data
|
6
|
+
|
7
|
+
## Remove this once Metadata can be built
|
8
|
+
## from Raw data (Scott, Fri Feb 5 20201)
|
9
|
+
data[:properties] = Properties.example
|
10
|
+
|
5
11
|
Messaging::Message::Metadata.build(data)
|
6
12
|
end
|
7
13
|
|
@@ -50,9 +56,7 @@ module Messaging
|
|
50
56
|
end
|
51
57
|
|
52
58
|
def self.properties
|
53
|
-
|
54
|
-
some_property: 'some property value'
|
55
|
-
}
|
59
|
+
Properties.example
|
56
60
|
end
|
57
61
|
|
58
62
|
def self.time
|
@@ -73,7 +77,7 @@ module Messaging
|
|
73
77
|
|
74
78
|
reply_stream_name: reply_stream_name,
|
75
79
|
|
76
|
-
properties:
|
80
|
+
properties: Properties.data,
|
77
81
|
|
78
82
|
time: time,
|
79
83
|
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Messaging
|
2
|
+
module Controls
|
3
|
+
module Properties
|
4
|
+
def self.example
|
5
|
+
[
|
6
|
+
SomeProperty.example,
|
7
|
+
SomeLocalProperty.example
|
8
|
+
]
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.data
|
12
|
+
[
|
13
|
+
SomeProperty.data,
|
14
|
+
SomeLocalProperty.data
|
15
|
+
]
|
16
|
+
end
|
17
|
+
|
18
|
+
module SomeProperty
|
19
|
+
def self.example
|
20
|
+
Messaging::Message::Metadata::Property.new(name, value)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.data
|
24
|
+
{
|
25
|
+
name: name,
|
26
|
+
value: value
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.name
|
31
|
+
:some_property
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.value
|
35
|
+
'some property value'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
module SomeLocalProperty
|
40
|
+
def self.example
|
41
|
+
Messaging::Message::Metadata::Property.new(name, value, true)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.data
|
45
|
+
{
|
46
|
+
name: name,
|
47
|
+
value: value,
|
48
|
+
local: true
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.name
|
53
|
+
:some_local_property
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.value
|
57
|
+
'some local property value'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/messaging/handle.rb
CHANGED
@@ -93,6 +93,8 @@ module Messaging
|
|
93
93
|
|
94
94
|
if message_or_message_data.is_a? MessageStore::MessageData::Read
|
95
95
|
name = Messaging::Message::Info.canonize_name(message_or_message_data.type)
|
96
|
+
elsif message_or_message_data.is_a? String
|
97
|
+
name = Messaging::Message::Info.canonize_name(message_or_message_data)
|
96
98
|
else
|
97
99
|
name = message_or_message_data.message_name
|
98
100
|
end
|
@@ -209,7 +211,12 @@ module Messaging
|
|
209
211
|
|
210
212
|
message_type = message.message_type
|
211
213
|
|
214
|
+
handler_logger.trace(tag: [:handle, :message_data]) { "Handling Message Data (Type: #{message_type}, Method: #{handler})" }
|
215
|
+
|
212
216
|
public_send(handler, message)
|
217
|
+
|
218
|
+
handler_logger.info(tags: [:handle, :message_data]) { "Handled message data (Type: #{message_data.type})" }
|
219
|
+
handler_logger.info(tags: [:data, :message_data]) { message_data.pretty_inspect }
|
213
220
|
else
|
214
221
|
if respond_to?(:handle)
|
215
222
|
message_type = message_data.type
|
@@ -21,7 +21,7 @@ module Messaging
|
|
21
21
|
receiver = receiver.build
|
22
22
|
end
|
23
23
|
|
24
|
-
if include.nil?
|
24
|
+
if copy.nil? && include.nil?
|
25
25
|
include = source.class.attribute_names
|
26
26
|
end
|
27
27
|
|
@@ -32,8 +32,13 @@ module Messaging
|
|
32
32
|
end
|
33
33
|
|
34
34
|
if metadata
|
35
|
-
metadata_include = source.metadata.class.attribute_names
|
35
|
+
metadata_include = source.metadata.class.attribute_names - [:properties]
|
36
|
+
|
36
37
|
SetAttributes.(receiver.metadata, source.metadata, include: metadata_include)
|
38
|
+
|
39
|
+
source.metadata.properties.each do |property|
|
40
|
+
receiver.metadata.properties << property.dup
|
41
|
+
end
|
37
42
|
end
|
38
43
|
|
39
44
|
receiver
|
@@ -33,7 +33,7 @@ module Messaging
|
|
33
33
|
|
34
34
|
attribute :reply_stream_name, String
|
35
35
|
|
36
|
-
attribute :properties,
|
36
|
+
attribute :properties, Array, default: -> { Array.new }
|
37
37
|
|
38
38
|
attribute :time, Time
|
39
39
|
|
@@ -59,6 +59,14 @@ module Messaging
|
|
59
59
|
self.correlation_stream_name = preceding_metadata.correlation_stream_name
|
60
60
|
|
61
61
|
self.reply_stream_name = preceding_metadata.reply_stream_name
|
62
|
+
|
63
|
+
preceding_metadata.properties.each do |property|
|
64
|
+
if property.local?
|
65
|
+
next
|
66
|
+
end
|
67
|
+
|
68
|
+
properties << property.dup
|
69
|
+
end
|
62
70
|
end
|
63
71
|
|
64
72
|
def follows?(preceding_metadata)
|
@@ -128,16 +136,37 @@ module Messaging
|
|
128
136
|
end
|
129
137
|
alias :correlates? :correlated?
|
130
138
|
|
131
|
-
def set_property(name, value)
|
132
|
-
|
139
|
+
def set_property(name, value, local: nil)
|
140
|
+
local ||= false
|
141
|
+
|
142
|
+
delete_property(name)
|
143
|
+
|
144
|
+
property = Property.new(name, value, local)
|
145
|
+
|
146
|
+
properties << property
|
147
|
+
|
148
|
+
property
|
149
|
+
end
|
150
|
+
|
151
|
+
def set_local_property(name, value, local: nil)
|
152
|
+
set_property(name, value, local: true)
|
133
153
|
end
|
134
154
|
|
135
155
|
def get_property(name)
|
136
|
-
properties
|
156
|
+
property = properties.find { |property| property.name == name }
|
157
|
+
property&.value
|
137
158
|
end
|
138
159
|
|
139
160
|
def delete_property(name)
|
140
|
-
properties.
|
161
|
+
i = properties.index { |property| property.name == name }
|
162
|
+
|
163
|
+
return nil if i.nil?
|
164
|
+
|
165
|
+
properties.delete_at(i).value
|
166
|
+
end
|
167
|
+
|
168
|
+
def clear_properties
|
169
|
+
properties.clear
|
141
170
|
end
|
142
171
|
|
143
172
|
def self.source_attribute_names
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Messaging
|
2
|
+
module Message
|
3
|
+
class Metadata
|
4
|
+
Property = Struct.new(
|
5
|
+
:name,
|
6
|
+
:value,
|
7
|
+
:local
|
8
|
+
) do
|
9
|
+
def local?
|
10
|
+
local == true
|
11
|
+
end
|
12
|
+
|
13
|
+
def ==(other)
|
14
|
+
equal =
|
15
|
+
name == other.name &&
|
16
|
+
value == other.value &&
|
17
|
+
!!local == !!other.local
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -26,8 +26,12 @@ module Messaging
|
|
26
26
|
|
27
27
|
metadata = message.metadata.to_h
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
properties = metadata[:properties]
|
30
|
+
|
31
|
+
if properties.empty?
|
32
|
+
metadata.delete(:properties)
|
33
|
+
else
|
34
|
+
metadata[:properties] = Properties.write(properties)
|
31
35
|
end
|
32
36
|
|
33
37
|
metadata.delete_if { |k, v| v.nil? }
|
@@ -37,9 +41,24 @@ module Messaging
|
|
37
41
|
message_data
|
38
42
|
end
|
39
43
|
|
44
|
+
module Properties
|
45
|
+
def self.write(properties)
|
46
|
+
properties.map do |property|
|
47
|
+
property_hash = property.to_h
|
48
|
+
|
49
|
+
if not property_hash[:local]
|
50
|
+
property_hash.delete(:local)
|
51
|
+
end
|
52
|
+
|
53
|
+
property_hash
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
40
58
|
def self.read(message_data)
|
41
59
|
data = message_data.to_h
|
42
60
|
|
61
|
+
## TODO change to positive "if"
|
43
62
|
unless data[:metadata].nil?
|
44
63
|
data[:metadata] = data[:metadata].clone
|
45
64
|
else
|
@@ -54,6 +73,16 @@ module Messaging
|
|
54
73
|
metadata[:global_position] = data[:global_position]
|
55
74
|
metadata[:time] = data[:time]
|
56
75
|
|
76
|
+
if metadata[:properties].nil?
|
77
|
+
metadata[:properties] = []
|
78
|
+
end
|
79
|
+
|
80
|
+
properties = metadata[:properties].map do |property_data|
|
81
|
+
Metadata::Property.new(*property_data.values_at(*Metadata::Property.members))
|
82
|
+
end
|
83
|
+
|
84
|
+
metadata[:properties] = properties
|
85
|
+
|
57
86
|
data
|
58
87
|
end
|
59
88
|
end
|
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.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Eventide Project
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: evt-message_store
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- lib/messaging/controls/message.rb
|
68
68
|
- lib/messaging/controls/message_data.rb
|
69
69
|
- lib/messaging/controls/metadata.rb
|
70
|
+
- lib/messaging/controls/properties.rb
|
70
71
|
- lib/messaging/controls/random.rb
|
71
72
|
- lib/messaging/controls/settings.rb
|
72
73
|
- lib/messaging/controls/stream_name.rb
|
@@ -81,6 +82,7 @@ files:
|
|
81
82
|
- lib/messaging/message/follow.rb
|
82
83
|
- lib/messaging/message/import.rb
|
83
84
|
- lib/messaging/message/metadata.rb
|
85
|
+
- lib/messaging/message/metadata/property.rb
|
84
86
|
- lib/messaging/message/sequence_accessor.rb
|
85
87
|
- lib/messaging/message/transform.rb
|
86
88
|
- lib/messaging/message_registry.rb
|