evt-messaging 0.18.1.0 → 0.19.0.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
  SHA1:
3
- metadata.gz: 807b9bba85a11cfbcb4882e089fd579082d62029
4
- data.tar.gz: 42d4aebb0205a6756c9f74b2066db41c7c622726
3
+ metadata.gz: 3601c7051816b61b0bff53ad401f897c926460b6
4
+ data.tar.gz: 956dbb82cd85977cd90d68615c9e4b1e2b3465f9
5
5
  SHA512:
6
- metadata.gz: 43091c83ebf1292f0fec90d4d9ace5fc45c68ec10a0a0ff007c394d6b0a93fd0693dc121d5bccab2b2f4f3fb6deb516d98c3fcb60af63cc7d55a41ded8d76a95
7
- data.tar.gz: f5a1ea112a849a754e547ad9dbff7d091917f6f9ca7c18d13f73135d73cad081ebb33254c92240a23a1f9ceb570ef728e3da8b9326717e78f2e470da9bc57da1
6
+ metadata.gz: 62df5c595eb662e56837d92f28c2a3825854296775e3831929f0ce45d093d922651896e29d8f48e79ff5e51c8be78c705fe051d89f3ab672f0f1792d499b80f4
7
+ data.tar.gz: 3191cdafe905adceb2b036d3140446cc9875c9107f7973683a266f7b8448361dfdb1b692c15ce57401c2e3f87af557bf709d26c509b30d9fef1fa4c28f43155b
@@ -8,6 +8,8 @@ require 'messaging/message'
8
8
  require 'messaging/message/metadata'
9
9
  require 'messaging/message/copy'
10
10
  require 'messaging/message/follow'
11
+ require 'messaging/message/sequence_attribute'
12
+ require 'messaging/message/sequenced'
11
13
 
12
14
  require 'messaging/message/transformer'
13
15
  require 'messaging/message/import'
@@ -1,6 +1,9 @@
1
+ require 'securerandom'
2
+
1
3
  require 'clock/controls'
2
4
  require 'message_store/controls'
3
5
 
6
+ require 'messaging/controls/random'
4
7
  require 'messaging/controls/time'
5
8
  require 'messaging/controls/id'
6
9
  require 'messaging/controls/stream_name'
@@ -48,6 +48,27 @@ module Messaging
48
48
  attribute :some_attribute
49
49
  end
50
50
 
51
+ module Sequenced
52
+ def self.example
53
+ message = Example.new
54
+
55
+ message.id = Message.id
56
+ message.some_attribute = Message.attribute
57
+ message.other_attribute = Message.other_attribute
58
+
59
+ message.metadata = Controls::Metadata.example
60
+
61
+ message
62
+ end
63
+
64
+ class Example
65
+ include Messaging::Message::Sequenced
66
+
67
+ attribute :some_attribute
68
+ attribute :other_attribute
69
+ end
70
+ end
71
+
51
72
  def self.message_class
52
73
  SomeMessage
53
74
  end
@@ -21,6 +21,10 @@ module Messaging
21
21
  11
22
22
  end
23
23
 
24
+ def self.causation_message_global_position
25
+ 222
26
+ end
27
+
24
28
  def self.correlation_stream_name
25
29
  "someCorrelation"
26
30
  end
@@ -56,6 +60,7 @@ module Messaging
56
60
 
57
61
  causation_message_stream_name: causation_message_stream_name,
58
62
  causation_message_position: causation_message_position,
63
+ causation_message_global_position: causation_message_global_position,
59
64
 
60
65
  correlation_stream_name: correlation_stream_name,
61
66
 
@@ -90,6 +95,80 @@ module Messaging
90
95
  data
91
96
  end
92
97
  end
98
+
99
+ module Random
100
+ def self.example
101
+ Messaging::Message::Metadata.build(data)
102
+ end
103
+
104
+ def self.source_message_stream_name
105
+ Controls::Random::Text.example
106
+ end
107
+
108
+ def self.source_message_position
109
+ Controls::Random::Number.example
110
+ end
111
+
112
+ def self.causation_message_stream_name
113
+ Controls::Random::Text.example
114
+ end
115
+
116
+ def self.causation_message_position
117
+ Controls::Random::Number.example
118
+ end
119
+
120
+ def self.causation_message_global_position
121
+ Controls::Random::Number.example
122
+ end
123
+
124
+ def self.correlation_stream_name
125
+ Controls::Random::Text.example
126
+ end
127
+
128
+ def self.reply_stream_name
129
+ Controls::Random::Text.example
130
+ end
131
+
132
+ def self.schema_version
133
+ Controls::Random::Number.example.to_s
134
+ end
135
+
136
+ def self.source_message_identifier
137
+ "#{source_message_stream_name}/#{source_message_position}"
138
+ end
139
+
140
+ def self.causation_message_identifier
141
+ "#{causation_message_stream_name}/#{causation_message_position}"
142
+ end
143
+
144
+ def self.global_position
145
+ Controls::Random::Number.example
146
+ end
147
+
148
+ def self.time
149
+ (::Time.now + Controls::Random::Number.example).utc
150
+ end
151
+
152
+ def self.data
153
+ {
154
+ source_message_stream_name: source_message_stream_name,
155
+ source_message_position: source_message_position,
156
+
157
+ causation_message_stream_name: causation_message_stream_name,
158
+ causation_message_position: causation_message_position,
159
+ causation_message_global_position: causation_message_global_position,
160
+
161
+ correlation_stream_name: correlation_stream_name,
162
+
163
+ reply_stream_name: reply_stream_name,
164
+
165
+ global_position: global_position,
166
+ time: time,
167
+
168
+ schema_version: schema_version
169
+ }
170
+ end
171
+ end
93
172
  end
94
173
  end
95
174
  end
@@ -0,0 +1,17 @@
1
+ module Messaging
2
+ module Controls
3
+ module Random
4
+ module Number
5
+ def self.example
6
+ rand(10000..999999)
7
+ end
8
+ end
9
+
10
+ module Text
11
+ def self.example
12
+ SecureRandom.hex
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -7,19 +7,39 @@ module Messaging
7
7
 
8
8
  attribute :source_message_stream_name, String
9
9
  alias :stream_name :source_message_stream_name
10
+ alias :stream_name= :source_message_stream_name=
11
+
12
+ ## TODO Plan: Switch to this in subsequent commit
13
+ # attribute :stream_name, String
14
+ # alias :source_message_stream_name :stream_name
15
+ # alias :source_message_stream_name= :stream_name=
16
+
10
17
  attribute :source_message_position, Integer
11
- alias :sequence :source_message_position
12
18
  alias :position :source_message_position
13
19
  alias :position= :source_message_position=
14
20
 
21
+ ## TODO Plan: Switch to this in subsequent commit
22
+ # attribute :position, Integer
23
+ # alias :source_message_position :position
24
+ # alias :source_message_position= :position=
25
+
26
+ ## TODO make this point to previous_message_global_position
27
+ # alias :sequence :source_message_position
28
+
15
29
  attribute :causation_message_stream_name, String
16
30
  attribute :causation_message_position, Integer
31
+ attribute :causation_message_global_position, Integer
32
+ alias :sequence :causation_message_global_position
33
+ alias :sequence= :causation_message_global_position=
17
34
 
18
35
  attribute :correlation_stream_name, String
19
36
 
20
37
  attribute :reply_stream_name, String
21
38
 
22
39
  attribute :global_position, Integer
40
+ alias :source_message_global_position :global_position
41
+ alias :source_message_global_position= :global_position=
42
+
23
43
  attribute :time, Time
24
44
 
25
45
  attribute :schema_version, String
@@ -37,6 +57,7 @@ module Messaging
37
57
  def follow(other_metadata)
38
58
  self.causation_message_stream_name = other_metadata.source_message_stream_name
39
59
  self.causation_message_position = other_metadata.source_message_position
60
+ self.causation_message_global_position = other_metadata.source_message_global_position
40
61
 
41
62
  self.correlation_stream_name = other_metadata.correlation_stream_name
42
63
 
@@ -45,6 +66,7 @@ module Messaging
45
66
 
46
67
  def follows?(other_metadata)
47
68
  causation_message_identifier == other_metadata.source_message_identifier &&
69
+ causation_message_global_position == other_metadata.source_message_global_position &&
48
70
  correlation_stream_name == other_metadata.correlation_stream_name &&
49
71
  reply_stream_name == other_metadata.reply_stream_name
50
72
  end
@@ -71,6 +93,7 @@ module Messaging
71
93
  alias :correlates? :correlated?
72
94
 
73
95
  def self.transient_attributes
96
+ ## TODO change global_position to source_message_global_position
74
97
  [
75
98
  :source_message_stream_name,
76
99
  :source_message_position,
@@ -0,0 +1,13 @@
1
+ module Messaging
2
+ module Message
3
+ module SequenceAttribute
4
+ def sequence
5
+ metadata.causation_message_global_position
6
+ end
7
+
8
+ def sequence=(val)
9
+ metadata.causation_message_global_position = val
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ module Messaging
2
+ module Message
3
+ module Sequenced
4
+ def self.included(cls)
5
+ cls.class_exec do
6
+ include Messaging::Message
7
+ include Messaging::Message::SequenceAttribute
8
+ end
9
+ end
10
+ end
11
+ end
12
+ 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: 0.18.1.0
4
+ version: 0.19.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: 2017-07-19 00:00:00.000000000 Z
11
+ date: 2017-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: evt-message_store
@@ -54,6 +54,7 @@ files:
54
54
  - lib/messaging/controls/message.rb
55
55
  - lib/messaging/controls/message_data.rb
56
56
  - lib/messaging/controls/metadata.rb
57
+ - lib/messaging/controls/random.rb
57
58
  - lib/messaging/controls/stream_name.rb
58
59
  - lib/messaging/controls/time.rb
59
60
  - lib/messaging/controls/write.rb
@@ -65,6 +66,8 @@ files:
65
66
  - lib/messaging/message/follow.rb
66
67
  - lib/messaging/message/import.rb
67
68
  - lib/messaging/message/metadata.rb
69
+ - lib/messaging/message/sequence_attribute.rb
70
+ - lib/messaging/message/sequenced.rb
68
71
  - lib/messaging/message/transformer.rb
69
72
  - lib/messaging/message_registry.rb
70
73
  - lib/messaging/stream_name.rb