evt-messaging 2.5.5.2 → 2.6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/messaging/controls.rb +3 -1
- data/lib/messaging/controls/local_properties.rb +39 -0
- data/lib/messaging/controls/metadata.rb +33 -5
- data/lib/messaging/controls/properties.rb +39 -0
- data/lib/messaging/handle.rb +2 -0
- data/lib/messaging/message/copy.rb +5 -1
- data/lib/messaging/message/metadata.rb +53 -0
- data/lib/messaging/message/transform.rb +11 -4
- 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: bdc052cd505024a0dc1c9ee66b8c7bf9233f1deb8efb4cc07f8bc67ac37dc1ca
|
4
|
+
data.tar.gz: 25087356a05e7d159345ef0f268d2fcb671dcac86f931236c7be25a49dd003d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdf114d68c3a8102adf5a675eb2b784e36e51882b08b66e9ffeffeaf5cc0597741ae70a2326b6d14db69c3ab2ed5c9a41566f98eadaae3fec653617fa88ce067
|
7
|
+
data.tar.gz: 9438c70a8643db857dd6102f2ae22c5f4ca71e4dde416096a303e267a89c8ed0b6c71730fde5f9c1a5c1ab66db65c9eaad19f2128a6cab2c2e6a8584cf8a3a7c
|
data/lib/messaging/controls.rb
CHANGED
@@ -7,9 +7,11 @@ 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/local_properties'
|
12
|
+
require 'messaging/controls/metadata'
|
10
13
|
require 'messaging/controls/message_data'
|
11
14
|
require 'messaging/controls/message'
|
12
|
-
require 'messaging/controls/metadata'
|
13
15
|
require 'messaging/controls/batch'
|
14
16
|
require 'messaging/controls/write'
|
15
17
|
require 'messaging/controls/settings'
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Messaging
|
2
|
+
module Controls
|
3
|
+
module LocalProperties
|
4
|
+
def self.example
|
5
|
+
{
|
6
|
+
SomeLocalProperty.name => SomeLocalProperty.value
|
7
|
+
}
|
8
|
+
end
|
9
|
+
|
10
|
+
module SomeLocalProperty
|
11
|
+
def self.name
|
12
|
+
:some_local_property
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.value
|
16
|
+
'some local property value'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module Random
|
21
|
+
def self.example
|
22
|
+
{
|
23
|
+
SomeLocalProperty.name => SomeLocalProperty.value
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
module SomeLocalProperty
|
28
|
+
def self.name
|
29
|
+
:some_local_property
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.value
|
33
|
+
SecureRandom.hex
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -2,6 +2,11 @@ module Messaging
|
|
2
2
|
module Controls
|
3
3
|
module Metadata
|
4
4
|
def self.example
|
5
|
+
data = self.data
|
6
|
+
|
7
|
+
data[:properties] = properties
|
8
|
+
data[:local_properties] = local_properties
|
9
|
+
|
5
10
|
Messaging::Message::Metadata.build(data)
|
6
11
|
end
|
7
12
|
|
@@ -50,15 +55,21 @@ module Messaging
|
|
50
55
|
end
|
51
56
|
|
52
57
|
def self.properties
|
53
|
-
|
54
|
-
some_property: 'some property value'
|
55
|
-
}
|
58
|
+
Properties.example
|
56
59
|
end
|
57
60
|
|
58
61
|
def self.time
|
59
62
|
Time::Raw.example
|
60
63
|
end
|
61
64
|
|
65
|
+
def self.properties
|
66
|
+
Properties.example
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.local_properties
|
70
|
+
LocalProperties.example
|
71
|
+
end
|
72
|
+
|
62
73
|
def self.data
|
63
74
|
{
|
64
75
|
stream_name: stream_name,
|
@@ -73,7 +84,8 @@ module Messaging
|
|
73
84
|
|
74
85
|
reply_stream_name: reply_stream_name,
|
75
86
|
|
76
|
-
properties:
|
87
|
+
properties: Properties.example,
|
88
|
+
local_properties: LocalProperties.example,
|
77
89
|
|
78
90
|
time: time,
|
79
91
|
|
@@ -106,6 +118,11 @@ module Messaging
|
|
106
118
|
|
107
119
|
module Random
|
108
120
|
def self.example
|
121
|
+
data = self.data
|
122
|
+
|
123
|
+
data[:properties] = properties
|
124
|
+
data[:local_properties] = local_properties
|
125
|
+
|
109
126
|
Messaging::Message::Metadata.build(data)
|
110
127
|
end
|
111
128
|
|
@@ -157,10 +174,19 @@ module Messaging
|
|
157
174
|
(::Time.now + Controls::Random::Number.example).utc
|
158
175
|
end
|
159
176
|
|
177
|
+
def self.properties
|
178
|
+
Properties::Random.example
|
179
|
+
end
|
180
|
+
|
181
|
+
def self.local_properties
|
182
|
+
LocalProperties::Random.example
|
183
|
+
end
|
184
|
+
|
160
185
|
def self.data
|
161
186
|
{
|
162
187
|
stream_name: stream_name,
|
163
188
|
position: position,
|
189
|
+
global_position: global_position,
|
164
190
|
|
165
191
|
causation_message_stream_name: causation_message_stream_name,
|
166
192
|
causation_message_position: causation_message_position,
|
@@ -170,7 +196,9 @@ module Messaging
|
|
170
196
|
|
171
197
|
reply_stream_name: reply_stream_name,
|
172
198
|
|
173
|
-
|
199
|
+
properties: Properties::Random.example,
|
200
|
+
local_properties: LocalProperties::Random.example,
|
201
|
+
|
174
202
|
time: time,
|
175
203
|
|
176
204
|
schema_version: schema_version
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Messaging
|
2
|
+
module Controls
|
3
|
+
module Properties
|
4
|
+
def self.example
|
5
|
+
{
|
6
|
+
SomeProperty.name => SomeProperty.value
|
7
|
+
}
|
8
|
+
end
|
9
|
+
|
10
|
+
module SomeProperty
|
11
|
+
def self.name
|
12
|
+
:some_property
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.value
|
16
|
+
'some property value'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module Random
|
21
|
+
def self.example
|
22
|
+
{
|
23
|
+
SomeProperty.name => SomeProperty.value
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
module SomeProperty
|
28
|
+
def self.name
|
29
|
+
:some_property
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.value
|
33
|
+
SecureRandom.hex
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
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
|
@@ -32,8 +32,12 @@ 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, :local_properties]
|
36
|
+
|
36
37
|
SetAttributes.(receiver.metadata, source.metadata, include: metadata_include)
|
38
|
+
|
39
|
+
receiver.metadata.properties = source.metadata.properties.dup
|
40
|
+
receiver.metadata.local_properties = source.metadata.local_properties.dup
|
37
41
|
end
|
38
42
|
|
39
43
|
receiver
|
@@ -34,6 +34,7 @@ module Messaging
|
|
34
34
|
attribute :reply_stream_name, String
|
35
35
|
|
36
36
|
attribute :properties, Hash, default: -> { Hash.new }
|
37
|
+
attribute :local_properties, Hash, default: -> { Hash.new }
|
37
38
|
|
38
39
|
attribute :time, Time
|
39
40
|
|
@@ -59,6 +60,10 @@ module Messaging
|
|
59
60
|
self.correlation_stream_name = preceding_metadata.correlation_stream_name
|
60
61
|
|
61
62
|
self.reply_stream_name = preceding_metadata.reply_stream_name
|
63
|
+
|
64
|
+
preceding_metadata.properties.each do |name, value|
|
65
|
+
properties[name] = value
|
66
|
+
end
|
62
67
|
end
|
63
68
|
|
64
69
|
def follows?(preceding_metadata)
|
@@ -129,17 +134,65 @@ module Messaging
|
|
129
134
|
alias :correlates? :correlated?
|
130
135
|
|
131
136
|
def set_property(name, value)
|
137
|
+
if not name.is_a?(Symbol)
|
138
|
+
raise Error, "Property name must be a symbol: #{name.inspect}"
|
139
|
+
end
|
140
|
+
|
132
141
|
properties[name] = value
|
142
|
+
|
143
|
+
value
|
133
144
|
end
|
134
145
|
|
135
146
|
def get_property(name)
|
147
|
+
if not name.is_a?(Symbol)
|
148
|
+
raise Error, "Property name must be a symbol: #{name.inspect}"
|
149
|
+
end
|
150
|
+
|
136
151
|
properties[name]
|
137
152
|
end
|
138
153
|
|
139
154
|
def delete_property(name)
|
155
|
+
if not name.is_a?(Symbol)
|
156
|
+
raise Error, "Property name must be a symbol: #{name.inspect}"
|
157
|
+
end
|
158
|
+
|
140
159
|
properties.delete(name)
|
141
160
|
end
|
142
161
|
|
162
|
+
def clear_properties
|
163
|
+
properties.clear
|
164
|
+
end
|
165
|
+
|
166
|
+
def set_local_property(name, value)
|
167
|
+
if not name.is_a?(Symbol)
|
168
|
+
raise Error, "Local property name must be a symbol: #{name.inspect}"
|
169
|
+
end
|
170
|
+
|
171
|
+
local_properties[name] = value
|
172
|
+
|
173
|
+
value
|
174
|
+
end
|
175
|
+
|
176
|
+
def get_local_property(name)
|
177
|
+
if not name.is_a?(Symbol)
|
178
|
+
raise Error, "Local property name must be a symbol: #{name.inspect}"
|
179
|
+
end
|
180
|
+
|
181
|
+
local_properties[name]
|
182
|
+
end
|
183
|
+
|
184
|
+
def delete_local_property(name)
|
185
|
+
if not name.is_a?(Symbol)
|
186
|
+
raise Error, "Local property name must be a symbol: #{name.inspect}"
|
187
|
+
end
|
188
|
+
|
189
|
+
local_properties.delete(name)
|
190
|
+
end
|
191
|
+
|
192
|
+
def clear_local_properties
|
193
|
+
local_properties.clear
|
194
|
+
end
|
195
|
+
|
143
196
|
def self.source_attribute_names
|
144
197
|
[
|
145
198
|
:stream_name,
|
@@ -27,7 +27,11 @@ module Messaging
|
|
27
27
|
metadata = message.metadata.to_h
|
28
28
|
|
29
29
|
if metadata[:properties].empty?
|
30
|
-
metadata
|
30
|
+
metadata.delete(:properties)
|
31
|
+
end
|
32
|
+
|
33
|
+
if metadata[:local_properties].empty?
|
34
|
+
metadata.delete(:local_properties)
|
31
35
|
end
|
32
36
|
|
33
37
|
metadata.delete_if { |k, v| v.nil? }
|
@@ -40,10 +44,10 @@ module Messaging
|
|
40
44
|
def self.read(message_data)
|
41
45
|
data = message_data.to_h
|
42
46
|
|
43
|
-
|
44
|
-
data[:metadata] = data[:metadata].clone
|
45
|
-
else
|
47
|
+
if data[:metadata].nil?
|
46
48
|
data[:metadata] = {}
|
49
|
+
else
|
50
|
+
data[:metadata] = data[:metadata].clone
|
47
51
|
end
|
48
52
|
|
49
53
|
metadata = data[:metadata]
|
@@ -54,6 +58,9 @@ module Messaging
|
|
54
58
|
metadata[:global_position] = data[:global_position]
|
55
59
|
metadata[:time] = data[:time]
|
56
60
|
|
61
|
+
metadata[:properties] ||= {}
|
62
|
+
metadata[:local_properties] ||= {}
|
63
|
+
|
57
64
|
data
|
58
65
|
end
|
59
66
|
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.
|
4
|
+
version: 2.6.0.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: 2021-
|
11
|
+
date: 2021-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: evt-message_store
|
@@ -64,9 +64,11 @@ files:
|
|
64
64
|
- lib/messaging/controls/batch.rb
|
65
65
|
- lib/messaging/controls/handler.rb
|
66
66
|
- lib/messaging/controls/id.rb
|
67
|
+
- lib/messaging/controls/local_properties.rb
|
67
68
|
- lib/messaging/controls/message.rb
|
68
69
|
- lib/messaging/controls/message_data.rb
|
69
70
|
- lib/messaging/controls/metadata.rb
|
71
|
+
- lib/messaging/controls/properties.rb
|
70
72
|
- lib/messaging/controls/random.rb
|
71
73
|
- lib/messaging/controls/settings.rb
|
72
74
|
- lib/messaging/controls/stream_name.rb
|