mimi-messaging 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mimi/messaging/adapters/memory.rb +42 -14
- data/lib/mimi/messaging/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0b464776f714d968a8d9ab990cde1e440358604
|
4
|
+
data.tar.gz: 72d61df40a62d4808d56c3218018df171d2c288d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb34142287f5cc906ce350b756999aa58dcf014cdf391db5c07c5f859e58efff3234425e2754562aa290b349781938b1ad04bdc289ba0d15394d5a1ba6a19431
|
7
|
+
data.tar.gz: 30da26107b66c684f5a7666d2978483b82604b900ed29613ab13cabc529596536200a85444a842e7e2bb2d949afeda65679f862873e5ea6385403d1e1e78a600
|
@@ -23,21 +23,39 @@ module Mimi
|
|
23
23
|
def stop
|
24
24
|
end
|
25
25
|
|
26
|
+
# Sends COMMAND to target
|
27
|
+
#
|
28
|
+
# @param target [String]
|
29
|
+
# @param message [Mimi::Messaging::Message]
|
30
|
+
# @param opts [Hash]
|
31
|
+
#
|
26
32
|
def command(target, message, opts = {})
|
27
|
-
|
28
|
-
dispatch_command(target,
|
33
|
+
raise ArgumentError, "Message is expected" unless message.is_a?(Mimi::Messaging::Message)
|
34
|
+
dispatch_command(target, message, opts)
|
29
35
|
nil
|
30
36
|
end
|
31
37
|
|
38
|
+
# Sends QUERY to target
|
39
|
+
#
|
40
|
+
# @param target [String]
|
41
|
+
# @param message [Mimi::Messaging::Message]
|
42
|
+
# @param opts [Hash]
|
43
|
+
#
|
32
44
|
def query(target, message, opts = {})
|
33
|
-
|
34
|
-
response_serialized = dispatch_query(target,
|
45
|
+
raise ArgumentError, "Message is expected" unless message.is_a?(Mimi::Messaging::Message)
|
46
|
+
response_serialized = dispatch_query(target, message, opts)
|
35
47
|
deserialize(response_serialized)
|
36
48
|
end
|
37
49
|
|
50
|
+
# Sends EVENT to target
|
51
|
+
#
|
52
|
+
# @param target [String]
|
53
|
+
# @param message [Mimi::Messaging::Message]
|
54
|
+
# @param opts [Hash]
|
55
|
+
#
|
38
56
|
def event(target, message, opts = {})
|
39
|
-
|
40
|
-
dispatch_event(target,
|
57
|
+
raise ArgumentError, "Message is expected" unless message.is_a?(Mimi::Messaging::Message)
|
58
|
+
dispatch_event(target, message, opts)
|
41
59
|
end
|
42
60
|
|
43
61
|
def start_request_processor(queue_name, processor, _opts = {})
|
@@ -67,24 +85,35 @@ module Mimi
|
|
67
85
|
|
68
86
|
private
|
69
87
|
|
70
|
-
|
88
|
+
# Simulates a transmitted message, following serialization/deserialization:
|
89
|
+
# message out -> message in
|
90
|
+
#
|
91
|
+
# @param message [Mimi::Messaging::Message]
|
92
|
+
# @return [Mimi::Messaging::Message]
|
93
|
+
#
|
94
|
+
def transmitted_message(message)
|
95
|
+
Mimi::Messaging::Message.new(
|
96
|
+
deserialize(serialize(message)),
|
97
|
+
message.headers
|
98
|
+
)
|
99
|
+
end
|
100
|
+
|
101
|
+
def dispatch_command(target, message, _opts = {})
|
71
102
|
queue_name, method_name = target.split("/")
|
72
|
-
message = deserialize(message_serialized)
|
73
103
|
return unless request_processors[queue_name]
|
74
104
|
|
75
105
|
# pick random processor serving the target
|
76
106
|
processor = request_processors[queue_name].sample
|
77
|
-
processor.call_command(method_name, message, {})
|
107
|
+
processor.call_command(method_name, transmitted_message(message), {})
|
78
108
|
end
|
79
109
|
|
80
|
-
def dispatch_query(target,
|
110
|
+
def dispatch_query(target, message, _opts = {})
|
81
111
|
queue_name, method_name = target.split("/")
|
82
|
-
message = deserialize(message_serialized)
|
83
112
|
raise Timeout::Error unless request_processors[queue_name]
|
84
113
|
|
85
114
|
# pick random processor serving the target
|
86
115
|
processor = request_processors[queue_name].sample
|
87
|
-
response = processor.call_query(method_name, message, {})
|
116
|
+
response = processor.call_query(method_name, transmitted_message(message), {})
|
88
117
|
serialize(response)
|
89
118
|
end
|
90
119
|
|
@@ -96,9 +125,8 @@ module Mimi
|
|
96
125
|
processors << same_queue_processors.sample
|
97
126
|
end
|
98
127
|
|
99
|
-
message = deserialize(message_serialized)
|
100
128
|
processors.each do |processor|
|
101
|
-
processor.call_event(event_type, message, {})
|
129
|
+
processor.call_event(event_type, transmitted_message(message), {})
|
102
130
|
end
|
103
131
|
end
|
104
132
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mimi-messaging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Kukushkin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mimi-core
|