evt-messaging 2.5.4.0 → 2.5.7.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 +6 -4
- data/lib/messaging/controls/properties.rb +61 -0
- data/lib/messaging/handle.rb +7 -0
- data/lib/messaging/message/copy.rb +1 -1
- data/lib/messaging/message/metadata.rb +41 -4
- data/lib/messaging/message/metadata/property.rb +22 -0
- data/lib/messaging/message/transform.rb +20 -2
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a5c611f9683e1398927dd4223a8cba0f1520ff54523aef003ccd5d86a00ab0a
|
4
|
+
data.tar.gz: 1263fa3a97c59fcaabe62b4f0699fb3128117be0fd847f7df3dbd4419f6a8a0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78f3bdccb3a7fdb31a46426223810cc9b6ef5108c4ac803ba1ba54cb2452a6e5a0bbe7e8209eaed03f8c35192bba484cd5d7983e26ff0f4544934a14eec936a0
|
7
|
+
data.tar.gz: 29ecd80c4d0a941b29d8b1081f21032ca3d82c8327c0e7fe8777555d77401e03d1e6d7f7f9bf2e63dc2ccb43415391ad1160a8b6f80965d404213922e93075ce
|
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,10 @@ module Messaging
|
|
2
2
|
module Controls
|
3
3
|
module Metadata
|
4
4
|
def self.example
|
5
|
+
data = self.data
|
6
|
+
|
7
|
+
data[:properties] = Properties.example
|
8
|
+
|
5
9
|
Messaging::Message::Metadata.build(data)
|
6
10
|
end
|
7
11
|
|
@@ -50,9 +54,7 @@ module Messaging
|
|
50
54
|
end
|
51
55
|
|
52
56
|
def self.properties
|
53
|
-
|
54
|
-
some_property: 'some property value'
|
55
|
-
}
|
57
|
+
Properties.example
|
56
58
|
end
|
57
59
|
|
58
60
|
def self.time
|
@@ -73,7 +75,7 @@ module Messaging
|
|
73
75
|
|
74
76
|
reply_stream_name: reply_stream_name,
|
75
77
|
|
76
|
-
properties:
|
78
|
+
properties: Properties.data,
|
77
79
|
|
78
80
|
time: time,
|
79
81
|
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Messaging
|
2
|
+
module Controls
|
3
|
+
module Properties
|
4
|
+
def self.example
|
5
|
+
[
|
6
|
+
SomeProperty.example,
|
7
|
+
SomeTransientProperty.example
|
8
|
+
]
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.data
|
12
|
+
[
|
13
|
+
SomeProperty.data,
|
14
|
+
SomeTransientProperty.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 SomeTransientProperty
|
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
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.name
|
52
|
+
:some_transient_property
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.value
|
56
|
+
'some transient property value'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
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
|
@@ -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,18 @@ 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.transient?
|
65
|
+
next
|
66
|
+
end
|
67
|
+
|
68
|
+
set_property(
|
69
|
+
property.name,
|
70
|
+
property.value,
|
71
|
+
transient: property.transient
|
72
|
+
)
|
73
|
+
end
|
62
74
|
end
|
63
75
|
|
64
76
|
def follows?(preceding_metadata)
|
@@ -128,12 +140,37 @@ module Messaging
|
|
128
140
|
end
|
129
141
|
alias :correlates? :correlated?
|
130
142
|
|
131
|
-
def set_property(name, value)
|
132
|
-
|
143
|
+
def set_property(name, value, transient: nil)
|
144
|
+
transient ||= false
|
145
|
+
|
146
|
+
delete_property(name)
|
147
|
+
|
148
|
+
property = Property.new(name, value, transient)
|
149
|
+
|
150
|
+
properties << property
|
151
|
+
|
152
|
+
property
|
153
|
+
end
|
154
|
+
|
155
|
+
def set_transient_property(name, value, transient: nil)
|
156
|
+
set_property(name, value, transient: true)
|
133
157
|
end
|
134
158
|
|
135
159
|
def get_property(name)
|
136
|
-
properties
|
160
|
+
property = properties.find { |property| property.name == name }
|
161
|
+
property&.value
|
162
|
+
end
|
163
|
+
|
164
|
+
def delete_property(name)
|
165
|
+
i = properties.index { |property| property.name == name }
|
166
|
+
|
167
|
+
return nil if i.nil?
|
168
|
+
|
169
|
+
properties.delete_at(i).value
|
170
|
+
end
|
171
|
+
|
172
|
+
def clear_properties
|
173
|
+
properties.clear
|
137
174
|
end
|
138
175
|
|
139
176
|
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
|
+
:transient
|
8
|
+
) do
|
9
|
+
def transient?
|
10
|
+
transient == true
|
11
|
+
end
|
12
|
+
|
13
|
+
def ==(other)
|
14
|
+
equal =
|
15
|
+
name == other.name &&
|
16
|
+
value == other.value &&
|
17
|
+
!!transient == !!other.transient
|
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,6 +41,20 @@ 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[:transient]
|
50
|
+
property_hash.delete(:transient)
|
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
|
|
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.7.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-01-22 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
|
@@ -106,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
108
|
- !ruby/object:Gem::Version
|
107
109
|
version: '0'
|
108
110
|
requirements: []
|
109
|
-
rubygems_version: 3.1.
|
111
|
+
rubygems_version: 3.1.4
|
110
112
|
signing_key:
|
111
113
|
specification_version: 4
|
112
114
|
summary: Common primitives for platform-specific messaging implementations for Eventide
|