evt-messaging 0.15.1.0 → 0.16.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: a082e8b174c468e522ed5cc3e7196640eb05f6bd
4
- data.tar.gz: 14fec7ed58a011bf50ef2fc821185b3e5d7e48d9
3
+ metadata.gz: accf64039c2587ab9ce5b4d334f72b1c18350399
4
+ data.tar.gz: 7d97eacb6307e1be46f17a7976be0b027ab63ee4
5
5
  SHA512:
6
- metadata.gz: 94d583e6a85c858204d0a35c4d126a61416bd144c6410dafe3fd2ec5d0dc4ecec006341ab23baf2bd017d32308d14d186d753c67962b6f3c36f919c1eff3e4d5
7
- data.tar.gz: 054f0f251e3f69ede8129119dbd761c855b32f8dbdcbaa5d3e062bddc18329ec00ed79b7c244d47002ff9825ffcd4bc152ba13e9e2b007732df5dc93c67ad188
6
+ metadata.gz: dff032d85a063bbe4ca4a871f1f9412ebffdf202dbbb240f6380434dc1dad0ad8022c97e68ca48cc838b57770a77569295ac7c06b4acfecd209d19de4fe8263e
7
+ data.tar.gz: 4f4caad9f0295fec47d663986798a025383bc001cf8b4b47e37e84e136291d6cddf66c5d0399e9114a5f6aecfd32dd2fcb7c155052c46ea2a39a1fbfc458b0b4
data/lib/messaging.rb CHANGED
@@ -1,7 +1,9 @@
1
- require 'event_source'
1
+ require 'message_store'
2
2
 
3
3
  require 'messaging/log'
4
4
 
5
+ require 'messaging/stream_name'
6
+
5
7
  require 'messaging/message'
6
8
  require 'messaging/message/metadata'
7
9
  require 'messaging/message/copy'
@@ -1,10 +1,10 @@
1
1
  require 'clock/controls'
2
- require 'event_source/controls'
2
+ require 'message_store/controls'
3
3
 
4
4
  require 'messaging/controls/time'
5
5
  require 'messaging/controls/id'
6
6
  require 'messaging/controls/stream_name'
7
- require 'messaging/controls/event_data'
7
+ require 'messaging/controls/message_data'
8
8
  require 'messaging/controls/message'
9
9
  require 'messaging/controls/metadata'
10
10
  require 'messaging/controls/batch'
@@ -9,8 +9,8 @@ module Messaging
9
9
  end
10
10
 
11
11
  values = [
12
- EventSource::Controls::RandomValue.example,
13
- EventSource::Controls::RandomValue.example
12
+ MessageStore::Controls::RandomValue.example,
13
+ MessageStore::Controls::RandomValue.example
14
14
  ]
15
15
 
16
16
  batch = Messages.example(id: id)
@@ -14,8 +14,8 @@ module Messaging
14
14
  class Example
15
15
  include Messaging::Handle
16
16
 
17
- def handle(event_data)
18
- event_data.data = 'some value set by handle method'
17
+ def handle(message_data)
18
+ message_data.data = 'some value set by handle method'
19
19
  end
20
20
  end
21
21
  end
@@ -29,8 +29,8 @@ module Messaging
29
29
  some_message.some_attribute = 'some attribute value set by handler'
30
30
  end
31
31
 
32
- def handle(event_data)
33
- event_data.data = 'some data value set by handler'
32
+ def handle(message_data)
33
+ message_data.data = 'some data value set by handler'
34
34
  end
35
35
  end
36
36
  end
@@ -1,5 +1,5 @@
1
1
  module Messaging
2
2
  module Controls
3
- ID = EventSource::Controls::ID
3
+ ID = MessageStore::Controls::ID
4
4
  end
5
5
  end
@@ -0,0 +1,5 @@
1
+ module Messaging
2
+ module Controls
3
+ MessageData = MessageStore::Controls::MessageData
4
+ end
5
+ end
@@ -5,19 +5,19 @@ module Messaging
5
5
  Messaging::Message::Metadata.build(data)
6
6
  end
7
7
 
8
- def self.source_event_stream_name
8
+ def self.source_message_stream_name
9
9
  'someSource'
10
10
  end
11
11
 
12
- def self.source_event_position
12
+ def self.source_message_position
13
13
  1
14
14
  end
15
15
 
16
- def self.causation_event_stream_name
16
+ def self.causation_message_stream_name
17
17
  "someCausation"
18
18
  end
19
19
 
20
- def self.causation_event_position
20
+ def self.causation_message_position
21
21
  11
22
22
  end
23
23
 
@@ -33,12 +33,12 @@ module Messaging
33
33
  '1.1'
34
34
  end
35
35
 
36
- def self.source_event_identifier
37
- "#{source_event_stream_name}/#{source_event_position}"
36
+ def self.source_message_identifier
37
+ "#{source_message_stream_name}/#{source_message_position}"
38
38
  end
39
39
 
40
- def self.causation_event_identifier
41
- "#{causation_event_stream_name}/#{causation_event_position}"
40
+ def self.causation_message_identifier
41
+ "#{causation_message_stream_name}/#{causation_message_position}"
42
42
  end
43
43
 
44
44
  def self.global_position
@@ -51,11 +51,11 @@ module Messaging
51
51
 
52
52
  def self.data
53
53
  {
54
- source_event_stream_name: source_event_stream_name,
55
- source_event_position: source_event_position,
54
+ source_message_stream_name: source_message_stream_name,
55
+ source_message_position: source_message_position,
56
56
 
57
- causation_event_stream_name: causation_event_stream_name,
58
- causation_event_position: causation_event_position,
57
+ causation_message_stream_name: causation_message_stream_name,
58
+ causation_message_position: causation_message_position,
59
59
 
60
60
  correlation_stream_name: correlation_stream_name,
61
61
 
@@ -1,6 +1,6 @@
1
1
  module Messaging
2
2
  module Controls
3
- StreamName = EventSource::Controls::StreamName
3
+ StreamName = MessageStore::Controls::StreamName
4
4
 
5
5
  module StreamName
6
6
  module Named
@@ -9,7 +9,7 @@ module Messaging
9
9
  end
10
10
 
11
11
  class Example
12
- include Messaging::Category
12
+ include Messaging::StreamName
13
13
 
14
14
  category :some_category
15
15
  end
@@ -33,17 +33,17 @@ module Messaging
33
33
  end
34
34
 
35
35
  module Call
36
- def call(message_or_event_data, strict: nil)
36
+ def call(message_or_message_data, strict: nil)
37
37
  instance = build(strict: strict)
38
- instance.(message_or_event_data)
38
+ instance.(message_or_message_data)
39
39
  end
40
40
  end
41
41
 
42
42
  module Info
43
43
  extend self
44
44
 
45
- def handler(message_or_event_data)
46
- name = handler_name(message_or_event_data)
45
+ def handler(message_or_message_data)
46
+ name = handler_name(message_or_message_data)
47
47
 
48
48
  if method_defined?(name)
49
49
  return name
@@ -52,17 +52,17 @@ module Messaging
52
52
  end
53
53
  end
54
54
 
55
- def handles?(message_or_event_data)
56
- method_defined? handler_name(message_or_event_data)
55
+ def handles?(message_or_message_data)
56
+ method_defined? handler_name(message_or_message_data)
57
57
  end
58
58
 
59
- def handler_name(message_or_event_data)
59
+ def handler_name(message_or_message_data)
60
60
  name = nil
61
61
 
62
- if message_or_event_data.is_a? EventSource::EventData::Read
63
- name = Messaging::Message::Info.canonize_name(message_or_event_data.type)
62
+ if message_or_message_data.is_a? MessageStore::MessageData::Read
63
+ name = Messaging::Message::Info.canonize_name(message_or_message_data.type)
64
64
  else
65
- name = message_or_event_data.message_name
65
+ name = message_or_message_data.message_name
66
66
  end
67
67
 
68
68
  "handle_#{name}"
@@ -111,11 +111,11 @@ module Messaging
111
111
  end
112
112
  end
113
113
 
114
- def call(message_or_event_data)
115
- if message_or_event_data.is_a? Message
116
- handle_message(message_or_event_data)
114
+ def call(message_or_message_data)
115
+ if message_or_message_data.is_a? Message
116
+ handle_message(message_or_message_data)
117
117
  else
118
- handle_event_data(message_or_event_data)
118
+ handle_message_data(message_or_message_data)
119
119
  end
120
120
  end
121
121
 
@@ -141,33 +141,33 @@ module Messaging
141
141
  message
142
142
  end
143
143
 
144
- def handle_event_data(event_data)
145
- handler_logger.trace(tags: [:handle, :event_data]) { "Handling event data (Type: #{event_data.type})" }
146
- handler_logger.trace(tags: [:data, :event_data, :handle]) { event_data.pretty_inspect }
144
+ def handle_message_data(message_data)
145
+ handler_logger.trace(tags: [:handle, :message_data]) { "Handling message data (Type: #{message_data.type})" }
146
+ handler_logger.trace(tags: [:data, :message_data, :handle]) { message_data.pretty_inspect }
147
147
 
148
148
  res = nil
149
149
 
150
- handler = self.class.handler(event_data)
150
+ handler = self.class.handler(message_data)
151
151
 
152
152
  unless handler.nil?
153
- message_name = Messaging::Message::Info.canonize_name(event_data.type)
153
+ message_name = Messaging::Message::Info.canonize_name(message_data.type)
154
154
  message_class = self.class.message_registry.get(message_name)
155
- res = Message::Import.(event_data, message_class)
155
+ res = Message::Import.(message_data, message_class)
156
156
  public_send(handler, res)
157
157
  else
158
158
  if respond_to?(:handle)
159
- res = handle(event_data)
159
+ res = handle(message_data)
160
160
  else
161
161
  if strict
162
- error_msg = "#{self.class.name} does not implement `handle'. Cannot handle event data."
162
+ error_msg = "#{self.class.name} does not implement `handle'. Cannot handle message data."
163
163
  handler_logger.error { error_msg }
164
164
  raise Error, error_msg
165
165
  end
166
166
  end
167
167
  end
168
168
 
169
- handler_logger.info(tags: [:handle, :event_data]) { "Handled event data (Type: #{event_data.type})" }
170
- handler_logger.info(tags: [:data, :event_data, :handle]) { event_data.pretty_inspect }
169
+ handler_logger.info(tags: [:handle, :message_data]) { "Handled message data (Type: #{message_data.type})" }
170
+ handler_logger.info(tags: [:data, :message_data, :handle]) { message_data.pretty_inspect }
171
171
 
172
172
  res
173
173
  end
@@ -2,7 +2,7 @@ module Messaging
2
2
  module Message
3
3
  module Export
4
4
  def self.call(message)
5
- Transform::Write.(message, :event_data)
5
+ Transform::Write.(message, :message_data)
6
6
  end
7
7
  end
8
8
  end
@@ -1,8 +1,8 @@
1
1
  module Messaging
2
2
  module Message
3
3
  module Import
4
- def self.call(event_data, message_class)
5
- Transform::Read.(event_data, :event_data, message_class)
4
+ def self.call(message_data, message_class)
5
+ Transform::Read.(message_data, :message_data, message_class)
6
6
  end
7
7
  end
8
8
  end
@@ -5,15 +5,15 @@ module Messaging
5
5
 
6
6
  include Schema::DataStructure
7
7
 
8
- attribute :source_event_stream_name, String
9
- alias :stream_name :source_event_stream_name
10
- attribute :source_event_position, Integer
11
- alias :sequence :source_event_position
12
- alias :position :source_event_position
13
- alias :position= :source_event_position=
8
+ attribute :source_message_stream_name, String
9
+ alias :stream_name :source_message_stream_name
10
+ attribute :source_message_position, Integer
11
+ alias :sequence :source_message_position
12
+ alias :position :source_message_position
13
+ alias :position= :source_message_position=
14
14
 
15
- attribute :causation_event_stream_name, String
16
- attribute :causation_event_position, Integer
15
+ attribute :causation_message_stream_name, String
16
+ attribute :causation_message_position, Integer
17
17
 
18
18
  attribute :correlation_stream_name, String
19
19
 
@@ -24,19 +24,19 @@ module Messaging
24
24
 
25
25
  attribute :schema_version, String
26
26
 
27
- def source_event_identifier
28
- return nil if source_event_stream_name.nil? || source_event_position.nil?
29
- "#{source_event_stream_name}/#{source_event_position}"
27
+ def source_message_identifier
28
+ return nil if source_message_stream_name.nil? || source_message_position.nil?
29
+ "#{source_message_stream_name}/#{source_message_position}"
30
30
  end
31
31
 
32
- def causation_event_identifier
33
- return nil if causation_event_stream_name.nil? || causation_event_position.nil?
34
- "#{causation_event_stream_name}/#{causation_event_position}"
32
+ def causation_message_identifier
33
+ return nil if causation_message_stream_name.nil? || causation_message_position.nil?
34
+ "#{causation_message_stream_name}/#{causation_message_position}"
35
35
  end
36
36
 
37
37
  def follow(other_metadata)
38
- self.causation_event_stream_name = other_metadata.source_event_stream_name
39
- self.causation_event_position = other_metadata.source_event_position
38
+ self.causation_message_stream_name = other_metadata.source_message_stream_name
39
+ self.causation_message_position = other_metadata.source_message_position
40
40
 
41
41
  self.correlation_stream_name = other_metadata.correlation_stream_name
42
42
 
@@ -44,7 +44,7 @@ module Messaging
44
44
  end
45
45
 
46
46
  def follows?(other_metadata)
47
- causation_event_identifier == other_metadata.source_event_identifier &&
47
+ causation_message_identifier == other_metadata.source_message_identifier &&
48
48
  correlation_stream_name == other_metadata.correlation_stream_name &&
49
49
  reply_stream_name == other_metadata.reply_stream_name
50
50
  end
@@ -59,8 +59,8 @@ module Messaging
59
59
 
60
60
  def self.transient_attributes
61
61
  [
62
- :source_event_stream_name,
63
- :source_event_position,
62
+ :source_message_stream_name,
63
+ :source_message_position,
64
64
  :global_position,
65
65
  :time
66
66
  ]
@@ -1,39 +1,39 @@
1
1
  module Messaging
2
2
  module Message
3
3
  module Transformer
4
- def self.event_data
5
- EventData
4
+ def self.message_data
5
+ MessageData
6
6
  end
7
7
 
8
8
  def self.raw_data(message)
9
9
  message
10
10
  end
11
11
 
12
- def self.instance(event_data_data, cls)
13
- instance = cls.build(event_data_data[:data], event_data_data[:metadata])
14
- instance.id = event_data_data[:id]
12
+ def self.instance(message_data_data, cls)
13
+ instance = cls.build(message_data_data[:data], message_data_data[:metadata])
14
+ instance.id = message_data_data[:id]
15
15
  instance
16
16
  end
17
17
 
18
- module EventData
18
+ module MessageData
19
19
  def self.write(message)
20
- event_data = EventSource::EventData::Write.build
20
+ message_data = MessageStore::MessageData::Write.build
21
21
 
22
- event_data.id = message.id
23
- event_data.type = message.message_type
22
+ message_data.id = message.id
23
+ message_data.type = message.message_type
24
24
 
25
- event_data.data = message.to_h
25
+ message_data.data = message.to_h
26
26
 
27
27
  metadata = message.metadata.to_h
28
28
  metadata.delete_if { |k, v| v.nil? }
29
29
 
30
- event_data.metadata = metadata
30
+ message_data.metadata = metadata
31
31
 
32
- event_data
32
+ message_data
33
33
  end
34
34
 
35
- def self.read(event_data)
36
- data = event_data.to_h
35
+ def self.read(message_data)
36
+ data = message_data.to_h
37
37
 
38
38
  unless data[:metadata].nil?
39
39
  data[:metadata] = data[:metadata].clone
@@ -43,8 +43,8 @@ module Messaging
43
43
 
44
44
  metadata = data[:metadata]
45
45
 
46
- metadata[:source_event_stream_name] = data[:stream_name]
47
- metadata[:source_event_position] = data[:position]
46
+ metadata[:source_message_stream_name] = data[:stream_name]
47
+ metadata[:source_message_position] = data[:position]
48
48
 
49
49
  metadata[:global_position] = data[:global_position]
50
50
  metadata[:time] = data[:time]
@@ -0,0 +1,39 @@
1
+ module Messaging
2
+ module StreamName
3
+ extend self
4
+
5
+ def self.included(cls)
6
+ cls.class_exec do
7
+ include Messaging::Category
8
+ end
9
+ end
10
+
11
+ def stream_name(id, category=nil, type: nil)
12
+ category ||= self.category
13
+ MessageStore::StreamName.stream_name(category, id, type: type)
14
+ end
15
+
16
+ def category_stream_name(category=nil)
17
+ category ||= self.category
18
+ category
19
+ end
20
+
21
+ def command_stream_name(id, category=nil)
22
+ category ||= self.category
23
+ MessageStore::StreamName.stream_name(category, id, type: 'command')
24
+ end
25
+
26
+ def command_category_stream_name(category=nil)
27
+ category ||= self.category
28
+ MessageStore::StreamName.stream_name(category, type: 'command')
29
+ end
30
+
31
+ def self.get_category(stream_name)
32
+ MessageStore::StreamName.get_category(stream_name)
33
+ end
34
+
35
+ def self.get_id(stream_name)
36
+ MessageStore::StreamName.get_id stream_name
37
+ end
38
+ end
39
+ end
@@ -6,7 +6,7 @@ module Messaging
6
6
  cls.class_exec do
7
7
  include Log::Dependency
8
8
 
9
- dependency :event_writer
9
+ dependency :message_writer
10
10
  dependency :telemetry, ::Telemetry
11
11
 
12
12
  cls.extend Build
@@ -51,15 +51,15 @@ module Messaging
51
51
 
52
52
  message_batch = Array(message_or_batch)
53
53
 
54
- event_data_batch = event_data_batch(message_batch, reply_stream_name)
55
- last_position = event_writer.(event_data_batch, stream_name, expected_version: expected_version)
54
+ message_data_batch = message_data_batch(message_batch, reply_stream_name)
55
+ last_position = message_writer.(message_data_batch, stream_name, expected_version: expected_version)
56
56
 
57
57
  unless message_or_batch.is_a? Array
58
58
  logger.info(tag: :write) { "Wrote message (Position: #{last_position}, Stream Name: #{stream_name}, Type: #{message_or_batch.class.message_type}, Expected Version: #{expected_version.inspect}, Reply Stream Name: #{reply_stream_name.inspect})" }
59
59
  else
60
60
  logger.info(tag: :write) { "Wrote batch (Position: #{last_position}, Stream Name: #{stream_name}, Expected Version: #{expected_version.inspect}, Reply Stream Name: #{reply_stream_name.inspect})" }
61
61
  end
62
- logger.info(tags: [:write, :data, :message]) { event_data_batch.pretty_inspect }
62
+ logger.info(tags: [:write, :data, :message]) { message_data_batch.pretty_inspect }
63
63
 
64
64
  message_batch.each do |message|
65
65
  telemetry.record :written, Telemetry::Data.new(message, stream_name, expected_version, reply_stream_name)
@@ -69,17 +69,17 @@ module Messaging
69
69
  end
70
70
  alias :write :call
71
71
 
72
- def event_data_batch(message_batch, reply_stream_name=nil)
73
- event_data_batch = []
72
+ def message_data_batch(message_batch, reply_stream_name=nil)
73
+ message_data_batch = []
74
74
  message_batch.each do |message|
75
75
  unless reply_stream_name.nil?
76
76
  message.metadata.reply_stream_name = reply_stream_name
77
77
  end
78
78
 
79
- event_data_batch << Message::Export.(message)
79
+ message_data_batch << Message::Export.(message)
80
80
  end
81
81
 
82
- event_data_batch
82
+ message_data_batch
83
83
  end
84
84
 
85
85
  def reply(message)
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evt-messaging
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.1.0
4
+ version: 0.16.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-04-30 00:00:00.000000000 Z
11
+ date: 2017-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: evt-event_source
14
+ name: evt-message_store
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -49,10 +49,10 @@ files:
49
49
  - lib/messaging/category.rb
50
50
  - lib/messaging/controls.rb
51
51
  - lib/messaging/controls/batch.rb
52
- - lib/messaging/controls/event_data.rb
53
52
  - lib/messaging/controls/handler.rb
54
53
  - lib/messaging/controls/id.rb
55
54
  - lib/messaging/controls/message.rb
55
+ - lib/messaging/controls/message_data.rb
56
56
  - lib/messaging/controls/metadata.rb
57
57
  - lib/messaging/controls/stream_name.rb
58
58
  - lib/messaging/controls/time.rb
@@ -67,6 +67,7 @@ files:
67
67
  - lib/messaging/message/metadata.rb
68
68
  - lib/messaging/message/transformer.rb
69
69
  - lib/messaging/message_registry.rb
70
+ - lib/messaging/stream_name.rb
70
71
  - lib/messaging/write.rb
71
72
  - lib/messaging/write/substitute.rb
72
73
  homepage: https://github.com/eventide-project/messaging
@@ -81,7 +82,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
82
  requirements:
82
83
  - - ">="
83
84
  - !ruby/object:Gem::Version
84
- version: 2.3.3
85
+ version: 2.4.0
85
86
  required_rubygems_version: !ruby/object:Gem::Requirement
86
87
  requirements:
87
88
  - - ">="
@@ -92,5 +93,5 @@ rubyforge_project:
92
93
  rubygems_version: 2.6.11
93
94
  signing_key:
94
95
  specification_version: 4
95
- summary: Messaging primitives for Eventide
96
+ summary: Common primitives for platform-specific messaging implementations for Eventide
96
97
  test_files: []
@@ -1,5 +0,0 @@
1
- module Messaging
2
- module Controls
3
- EventData = EventSource::Controls::EventData
4
- end
5
- end