mimi-messaging-sqs_sns 0.1.5 → 0.2.0
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/sqs_sns/adapter.rb +27 -20
- data/lib/mimi/messaging/sqs_sns/version.rb +1 -1
- data/mimi-messaging-sqs_sns.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d47fc3876131459a7e72da66b375a26a208f370
|
4
|
+
data.tar.gz: ceb906309a79390bd9aa4f0a3db08c5db0ab9a86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ade51ba691163a98abc1c4b408e5f1ca37d4097c5cc63149de10a984b34def353b0cb192117ceec4a70370aa782c3de4ff20b22cebe458a43a69ed3ad654c2a2
|
7
|
+
data.tar.gz: 560f8d00382b7ce6a49b6e02d512389e84568c9041fa1e4b5a1f9e036c51897ac39fff8c1f662d4d130088f2b93f29a552d74038c6f0c052e032df532edba95c
|
@@ -75,22 +75,22 @@ module Mimi
|
|
75
75
|
# Mimi::Messaging.command("users/create", name: "John Smith")
|
76
76
|
#
|
77
77
|
# @param target [String] "<queue>/<method>"
|
78
|
-
# @param message [Hash]
|
78
|
+
# @param message [Hash,Mimi::Messaging::Message]
|
79
79
|
# @param opts [Hash] additional adapter-specific options
|
80
80
|
#
|
81
81
|
# @return nil
|
82
82
|
#
|
83
83
|
def command(target, message, _opts = {})
|
84
84
|
queue_name, method_name = target.split("/")
|
85
|
-
|
85
|
+
message = Mimi::Messaging::Message.new(message, __method: method_name)
|
86
86
|
queue_url = find_queue(queue_name)
|
87
|
-
deliver_message(
|
87
|
+
deliver_message(queue_url, message)
|
88
88
|
end
|
89
89
|
|
90
90
|
# Executes the query to the given target and returns response
|
91
91
|
#
|
92
92
|
# @param target [String] "<queue>/<method>"
|
93
|
-
# @param message [Hash]
|
93
|
+
# @param message [Hash,Mimi::Messaging::Message]
|
94
94
|
# @param opts [Hash] additional options, e.g. :timeout
|
95
95
|
#
|
96
96
|
# @return [Hash]
|
@@ -98,18 +98,17 @@ module Mimi
|
|
98
98
|
#
|
99
99
|
def query(target, message, opts = {})
|
100
100
|
queue_name, method_name = target.split("/")
|
101
|
-
message_payload = serialize(message)
|
102
101
|
queue_url = find_queue(queue_name)
|
103
102
|
request_id = SecureRandom.hex(8)
|
104
103
|
reply_queue = reply_listener.register_request_id(request_id)
|
105
104
|
|
106
|
-
|
107
|
-
|
108
|
-
queue_url,
|
105
|
+
message = Mimi::Messaging::Message.new(
|
106
|
+
message,
|
109
107
|
__method: method_name,
|
110
108
|
__reply_queue_url: reply_listener.reply_queue_url,
|
111
109
|
__request_id: request_id
|
112
110
|
)
|
111
|
+
deliver_message(queue_url, message)
|
113
112
|
timeout = opts[:timeout] || options[:mq_default_query_timeout]
|
114
113
|
response = nil
|
115
114
|
Timeout::timeout(timeout) do
|
@@ -140,15 +139,21 @@ module Mimi
|
|
140
139
|
opts = opts.dup
|
141
140
|
queue_url = find_or_create_queue(queue_name)
|
142
141
|
@consumers << Consumer.new(self, queue_url) do |m|
|
143
|
-
message =
|
144
|
-
|
145
|
-
|
146
|
-
|
142
|
+
message = Mimi::Messaging::Message.new(
|
143
|
+
deserialize(m.body),
|
144
|
+
deserialize_headers(m)
|
145
|
+
)
|
146
|
+
method_name = message.headers[:__method]
|
147
|
+
reply_to = message.headers[:__reply_queue_url]
|
147
148
|
if reply_to
|
148
|
-
response = processor.call_query(method_name, message,
|
149
|
-
|
149
|
+
response = processor.call_query(method_name, message, {})
|
150
|
+
response_message = Mimi::Messaging::Message.new(
|
151
|
+
response,
|
152
|
+
__request_id: message.headers[:__request_id]
|
153
|
+
)
|
154
|
+
deliver_message(reply_to, response_message)
|
150
155
|
else
|
151
|
-
processor.call_command(method_name, message,
|
156
|
+
processor.call_command(method_name, message, {})
|
152
157
|
end
|
153
158
|
end
|
154
159
|
end
|
@@ -204,17 +209,19 @@ module Mimi
|
|
204
209
|
|
205
210
|
# Delivers a message to a queue with given URL.
|
206
211
|
#
|
207
|
-
# @param message [String]
|
208
212
|
# @param queue_url [String]
|
209
|
-
# @param
|
213
|
+
# @param message [Mimi::Messaging::Message]
|
210
214
|
#
|
211
|
-
def deliver_message(
|
215
|
+
def deliver_message(queue_url, message)
|
212
216
|
raise ArgumentError, "Non-empty queue URL is expected" unless queue_url
|
217
|
+
unless message.is_a?(Mimi::Messaging::Message)
|
218
|
+
raise ArgumentError, "Message is expected as argument"
|
219
|
+
end
|
213
220
|
Mimi::Messaging.log "Delivering message to: #{queue_url}"
|
214
221
|
sqs_client.send_message(
|
215
222
|
queue_url: queue_url,
|
216
|
-
message_body: message,
|
217
|
-
message_attributes: headers.map do |k, v|
|
223
|
+
message_body: serialize(message),
|
224
|
+
message_attributes: message.headers.map do |k, v|
|
218
225
|
[k.to_s, { data_type: "String", string_value: v.to_s }]
|
219
226
|
end.to_h
|
220
227
|
)
|
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
34
|
spec.require_paths = ["lib"]
|
35
35
|
|
36
|
-
spec.add_dependency "mimi-messaging", "~> 1.
|
36
|
+
spec.add_dependency "mimi-messaging", "~> 1.1"
|
37
37
|
spec.add_dependency "aws-sdk-sqs", "~> 1.22"
|
38
38
|
spec.add_dependency "aws-sdk-sns", "~> 1.19"
|
39
39
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mimi-messaging-sqs_sns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Kukushkin
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: aws-sdk-sqs
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|