evt-messaging 2.5.8.1 → 2.6.0.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 +0 -1
- data/lib/messaging/controls.rb +1 -0
- data/lib/messaging/controls/local_properties.rb +39 -0
- data/lib/messaging/controls/metadata.rb +29 -5
- data/lib/messaging/controls/properties.rb +13 -36
- data/lib/messaging/message/copy.rb +3 -4
- data/lib/messaging/message/metadata.rb +42 -30
- data/lib/messaging/message/transform.rb +10 -32
- metadata +3 -3
- data/lib/messaging/message/metadata/property.rb +0 -22
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.rb
CHANGED
@@ -7,7 +7,6 @@ require 'messaging/stream_name'
|
|
7
7
|
|
8
8
|
require 'messaging/message'
|
9
9
|
require 'messaging/message/metadata'
|
10
|
-
require 'messaging/message/metadata/property'
|
11
10
|
require 'messaging/message/copy'
|
12
11
|
require 'messaging/message/follow'
|
13
12
|
require 'messaging/message/sequence_accessor'
|
data/lib/messaging/controls.rb
CHANGED
@@ -8,6 +8,7 @@ require 'messaging/controls/time'
|
|
8
8
|
require 'messaging/controls/id'
|
9
9
|
require 'messaging/controls/stream_name'
|
10
10
|
require 'messaging/controls/properties'
|
11
|
+
require 'messaging/controls/local_properties'
|
11
12
|
require 'messaging/controls/metadata'
|
12
13
|
require 'messaging/controls/message_data'
|
13
14
|
require 'messaging/controls/message'
|
@@ -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
|
@@ -4,9 +4,8 @@ module Messaging
|
|
4
4
|
def self.example
|
5
5
|
data = self.data
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
data[:properties] = Properties.example
|
7
|
+
data[:properties] = properties
|
8
|
+
data[:local_properties] = local_properties
|
10
9
|
|
11
10
|
Messaging::Message::Metadata.build(data)
|
12
11
|
end
|
@@ -63,6 +62,14 @@ module Messaging
|
|
63
62
|
Time::Raw.example
|
64
63
|
end
|
65
64
|
|
65
|
+
def self.properties
|
66
|
+
Properties.example
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.local_properties
|
70
|
+
LocalProperties.example
|
71
|
+
end
|
72
|
+
|
66
73
|
def self.data
|
67
74
|
{
|
68
75
|
stream_name: stream_name,
|
@@ -77,7 +84,8 @@ module Messaging
|
|
77
84
|
|
78
85
|
reply_stream_name: reply_stream_name,
|
79
86
|
|
80
|
-
properties: Properties.
|
87
|
+
properties: Properties.example,
|
88
|
+
local_properties: LocalProperties.example,
|
81
89
|
|
82
90
|
time: time,
|
83
91
|
|
@@ -110,6 +118,11 @@ module Messaging
|
|
110
118
|
|
111
119
|
module Random
|
112
120
|
def self.example
|
121
|
+
data = self.data
|
122
|
+
|
123
|
+
data[:properties] = properties
|
124
|
+
data[:local_properties] = local_properties
|
125
|
+
|
113
126
|
Messaging::Message::Metadata.build(data)
|
114
127
|
end
|
115
128
|
|
@@ -161,10 +174,19 @@ module Messaging
|
|
161
174
|
(::Time.now + Controls::Random::Number.example).utc
|
162
175
|
end
|
163
176
|
|
177
|
+
def self.properties
|
178
|
+
Properties::Random.example
|
179
|
+
end
|
180
|
+
|
181
|
+
def self.local_properties
|
182
|
+
LocalProperties::Random.example
|
183
|
+
end
|
184
|
+
|
164
185
|
def self.data
|
165
186
|
{
|
166
187
|
stream_name: stream_name,
|
167
188
|
position: position,
|
189
|
+
global_position: global_position,
|
168
190
|
|
169
191
|
causation_message_stream_name: causation_message_stream_name,
|
170
192
|
causation_message_position: causation_message_position,
|
@@ -174,7 +196,9 @@ module Messaging
|
|
174
196
|
|
175
197
|
reply_stream_name: reply_stream_name,
|
176
198
|
|
177
|
-
|
199
|
+
properties: Properties::Random.example,
|
200
|
+
local_properties: LocalProperties::Random.example,
|
201
|
+
|
178
202
|
time: time,
|
179
203
|
|
180
204
|
schema_version: schema_version
|
@@ -2,33 +2,14 @@ module Messaging
|
|
2
2
|
module Controls
|
3
3
|
module Properties
|
4
4
|
def self.example
|
5
|
-
|
6
|
-
SomeProperty.
|
7
|
-
|
8
|
-
]
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.data
|
12
|
-
[
|
13
|
-
SomeProperty.data,
|
14
|
-
SomeLocalProperty.data
|
15
|
-
]
|
5
|
+
{
|
6
|
+
SomeProperty.name => SomeProperty.value
|
7
|
+
}
|
16
8
|
end
|
17
9
|
|
18
10
|
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
11
|
def self.name
|
31
|
-
|
12
|
+
:some_property
|
32
13
|
end
|
33
14
|
|
34
15
|
def self.value
|
@@ -36,25 +17,21 @@ module Messaging
|
|
36
17
|
end
|
37
18
|
end
|
38
19
|
|
39
|
-
module
|
20
|
+
module Random
|
40
21
|
def self.example
|
41
|
-
Messaging::Message::Metadata::Property.new(name, value, true)
|
42
|
-
end
|
43
|
-
|
44
|
-
def self.data
|
45
22
|
{
|
46
|
-
name
|
47
|
-
value: value,
|
48
|
-
local: true
|
23
|
+
SomeProperty.name => SomeProperty.value
|
49
24
|
}
|
50
25
|
end
|
51
26
|
|
52
|
-
|
53
|
-
|
54
|
-
|
27
|
+
module SomeProperty
|
28
|
+
def self.name
|
29
|
+
:some_property
|
30
|
+
end
|
55
31
|
|
56
|
-
|
57
|
-
|
32
|
+
def self.value
|
33
|
+
SecureRandom.hex
|
34
|
+
end
|
58
35
|
end
|
59
36
|
end
|
60
37
|
end
|
@@ -32,13 +32,12 @@ module Messaging
|
|
32
32
|
end
|
33
33
|
|
34
34
|
if metadata
|
35
|
-
metadata_include = source.metadata.class.attribute_names - [:properties]
|
35
|
+
metadata_include = source.metadata.class.attribute_names - [:properties, :local_properties]
|
36
36
|
|
37
37
|
SetAttributes.(receiver.metadata, source.metadata, include: metadata_include)
|
38
38
|
|
39
|
-
source.metadata.properties.
|
40
|
-
|
41
|
-
end
|
39
|
+
receiver.metadata.properties = source.metadata.properties.dup
|
40
|
+
receiver.metadata.local_properties = source.metadata.local_properties.dup
|
42
41
|
end
|
43
42
|
|
44
43
|
receiver
|
@@ -33,7 +33,8 @@ module Messaging
|
|
33
33
|
|
34
34
|
attribute :reply_stream_name, String
|
35
35
|
|
36
|
-
attribute :properties,
|
36
|
+
attribute :properties, Hash, default: -> { Hash.new }
|
37
|
+
attribute :local_properties, Hash, default: -> { Hash.new }
|
37
38
|
|
38
39
|
attribute :time, Time
|
39
40
|
|
@@ -60,12 +61,8 @@ module Messaging
|
|
60
61
|
|
61
62
|
self.reply_stream_name = preceding_metadata.reply_stream_name
|
62
63
|
|
63
|
-
preceding_metadata.properties.each do |
|
64
|
-
|
65
|
-
next
|
66
|
-
end
|
67
|
-
|
68
|
-
properties << property.dup
|
64
|
+
preceding_metadata.properties.each do |name, value|
|
65
|
+
properties[name] = value
|
69
66
|
end
|
70
67
|
end
|
71
68
|
|
@@ -136,49 +133,64 @@ module Messaging
|
|
136
133
|
end
|
137
134
|
alias :correlates? :correlated?
|
138
135
|
|
139
|
-
def set_property(name, value
|
140
|
-
if not name.is_a?(
|
141
|
-
raise Error, "Property name must be a
|
136
|
+
def set_property(name, value)
|
137
|
+
if not name.is_a?(Symbol)
|
138
|
+
raise Error, "Property name must be a symbol: #{name.inspect}"
|
142
139
|
end
|
143
140
|
|
144
|
-
|
141
|
+
properties[name] = value
|
145
142
|
|
146
|
-
|
143
|
+
value
|
144
|
+
end
|
145
|
+
|
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
|
147
150
|
|
148
|
-
|
151
|
+
properties[name]
|
152
|
+
end
|
149
153
|
|
150
|
-
|
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
|
151
158
|
|
152
|
-
|
159
|
+
properties.delete(name)
|
153
160
|
end
|
154
161
|
|
155
|
-
def
|
156
|
-
|
162
|
+
def clear_properties
|
163
|
+
properties.clear
|
157
164
|
end
|
158
165
|
|
159
|
-
def
|
160
|
-
if not name.is_a?(
|
161
|
-
raise Error, "
|
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}"
|
162
169
|
end
|
163
170
|
|
164
|
-
|
165
|
-
|
171
|
+
local_properties[name] = value
|
172
|
+
|
173
|
+
value
|
166
174
|
end
|
167
175
|
|
168
|
-
def
|
169
|
-
if not name.is_a?(
|
170
|
-
raise Error, "
|
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}"
|
171
179
|
end
|
172
180
|
|
173
|
-
|
181
|
+
local_properties[name]
|
182
|
+
end
|
174
183
|
|
175
|
-
|
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
|
176
188
|
|
177
|
-
|
189
|
+
local_properties.delete(name)
|
178
190
|
end
|
179
191
|
|
180
|
-
def
|
181
|
-
|
192
|
+
def clear_local_properties
|
193
|
+
local_properties.clear
|
182
194
|
end
|
183
195
|
|
184
196
|
def self.source_attribute_names
|
@@ -26,12 +26,12 @@ module Messaging
|
|
26
26
|
|
27
27
|
metadata = message.metadata.to_h
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
if properties.empty?
|
29
|
+
if metadata[:properties].empty?
|
32
30
|
metadata.delete(:properties)
|
33
|
-
|
34
|
-
|
31
|
+
end
|
32
|
+
|
33
|
+
if metadata[:local_properties].empty?
|
34
|
+
metadata.delete(:local_properties)
|
35
35
|
end
|
36
36
|
|
37
37
|
metadata.delete_if { |k, v| v.nil? }
|
@@ -41,28 +41,13 @@ module Messaging
|
|
41
41
|
message_data
|
42
42
|
end
|
43
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
|
-
|
58
44
|
def self.read(message_data)
|
59
45
|
data = message_data.to_h
|
60
46
|
|
61
|
-
|
62
|
-
unless data[:metadata].nil?
|
63
|
-
data[:metadata] = data[:metadata].clone
|
64
|
-
else
|
47
|
+
if data[:metadata].nil?
|
65
48
|
data[:metadata] = {}
|
49
|
+
else
|
50
|
+
data[:metadata] = data[:metadata].clone
|
66
51
|
end
|
67
52
|
|
68
53
|
metadata = data[:metadata]
|
@@ -73,15 +58,8 @@ module Messaging
|
|
73
58
|
metadata[:global_position] = data[:global_position]
|
74
59
|
metadata[:time] = data[:time]
|
75
60
|
|
76
|
-
|
77
|
-
|
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
|
61
|
+
metadata[:properties] ||= {}
|
62
|
+
metadata[:local_properties] ||= {}
|
85
63
|
|
86
64
|
data
|
87
65
|
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,6 +64,7 @@ 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
|
@@ -82,7 +83,6 @@ files:
|
|
82
83
|
- lib/messaging/message/follow.rb
|
83
84
|
- lib/messaging/message/import.rb
|
84
85
|
- lib/messaging/message/metadata.rb
|
85
|
-
- lib/messaging/message/metadata/property.rb
|
86
86
|
- lib/messaging/message/sequence_accessor.rb
|
87
87
|
- lib/messaging/message/transform.rb
|
88
88
|
- lib/messaging/message_registry.rb
|
@@ -1,22 +0,0 @@
|
|
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
|