alchemy-flux 0.1.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5820f4295838010b3f94ee73e729657d22cced0f
4
- data.tar.gz: 040f7690b3b91f7b86915dc77973014d3a58c304
3
+ metadata.gz: 79536f814a7c62f09925bf33d0ba8f5faaff4d72
4
+ data.tar.gz: c165d0e7b4023b3199bac181896c0b796a5e7fa7
5
5
  SHA512:
6
- metadata.gz: ca7a76d755a04790abc72273ca044df9f65bb08b103e0a3ba1e7b68b4491e1035ee37bc77b573c8d488821af800c2bbe73f8f718449021fc13d8c7fb67ac8297
7
- data.tar.gz: 74d842ddead3cae1cdfa6ad663efd2db3c352d1cb4a2bfb1c4cedcc4eae1590d09f26a1ab7fe5595f6fd3c11d282881a608d0c31a4fe490627292c8767f54a69
6
+ metadata.gz: a55a9a147d17e23b32db10217a94816aada57385c0d86ebc02c70cf42d87f466726593e4919585669289401ffc92ffa2093e0748023b8621b989bedd9af68f7f
7
+ data.tar.gz: 628d1735463517bcb0f112c695e7461af86d95e6d152e5fd79c3f9b0b69cd8d1e06c674fc48e40ef0040fe17424e6c8f7623e8f20b0e4f9ffb3db0ab59c0a8cf
@@ -1,7 +1,7 @@
1
1
  require 'time'
2
2
  require 'amqp'
3
3
  require "uuidtools"
4
- require 'msgpack'
4
+ require 'json'
5
5
 
6
6
  require 'alchemy-flux/flux_rack_handler.rb'
7
7
 
@@ -140,25 +140,25 @@ module AlchemyFlux
140
140
 
141
141
  @service_queue = @channel.queue( @service_queue_name, {:durable => true})
142
142
  @service_queue.subscribe({:ack => true}) do |metadata, payload|
143
- payload = MessagePack.unpack(payload)
143
+ payload = JSON.parse(payload)
144
144
  process_service_queue_message(metadata, payload)
145
145
  end
146
146
 
147
147
  response_queue = @channel.queue(@response_queue_name, {:exclusive => true, :auto_delete => true})
148
148
  response_queue.subscribe({}) do |metadata, payload|
149
- payload = MessagePack.unpack(payload)
149
+ payload = JSON.parse(payload)
150
150
  process_response_queue_message(metadata, payload)
151
151
  end
152
152
 
153
153
  @channel.default_exchange.on_return do |basic_return, frame, payload|
154
- payload = MessagePack.unpack(payload)
154
+ payload = JSON.parse(payload)
155
155
  process_returned_message(basic_return, frame.properties, payload)
156
156
  end
157
157
 
158
158
  # RESOURCES HANDLE
159
159
  @resources_exchange = @channel.topic("resources.exchange", {:durable => true})
160
160
  @resources_exchange.on_return do |basic_return, frame, payload|
161
- payload = MessagePack.unpack(payload)
161
+ payload = JSON.parse(payload)
162
162
  process_returned_message(basic_return, frame.properties, payload)
163
163
  end
164
164
 
@@ -229,7 +229,6 @@ module AlchemyFlux
229
229
  rescue Exception => e
230
230
  puts "Service Fn Error " + e.inspect
231
231
 
232
- # Returning Hoodoo formatted Error code (just in case service doesnt handle the error, it should!)
233
232
  {
234
233
  'status_code' => 500,
235
234
  'headers' => {'Content-Type' => 'application/json; charset=utf-8'},
@@ -237,7 +236,11 @@ module AlchemyFlux
237
236
  'kind' => "Errors",
238
237
  'id' => AlchemyFlux::Service.generateUUID(),
239
238
  'created_at' => Time.now.utc.iso8601,
240
- 'errors' => [{'code' => 'platform.fault', 'message' => 'An unexpected error occurred'}]
239
+ 'errors' => [{
240
+ 'code' => 'alchemy-flux.error',
241
+ 'message' => 'An unexpected error occurred',
242
+ 'message_id' => message_replying_to
243
+ }]
241
244
  }
242
245
  }
243
246
  end
@@ -248,12 +251,16 @@ module AlchemyFlux
248
251
  if result == AlchemyFlux::NAckError
249
252
  @service_queue.reject(delivery_tag)
250
253
  else
251
- options = {
252
- :message_id => this_message_id,
253
- :correlation_id => message_replying_to,
254
- :type => 'http_response'
255
- }
256
- send_message(@channel.default_exchange, service_to_reply_to, result, options)
254
+ #if there is a service to reply to then reply, else ignore
255
+
256
+ if service_to_reply_to
257
+ send_message(@channel.default_exchange, service_to_reply_to, result, {
258
+ :message_id => this_message_id,
259
+ :correlation_id => message_replying_to,
260
+ :type => 'http_response'
261
+ })
262
+ end
263
+
257
264
  @processing_messages -= 1
258
265
  @service_queue.acknowledge(delivery_tag)
259
266
  end
@@ -294,7 +301,7 @@ module AlchemyFlux
294
301
  # *options*:: The message options
295
302
  def send_message(exchange, routing_key, message, options)
296
303
  message_options = options.merge({:routing_key => routing_key})
297
- message = MessagePack.pack(message)
304
+ message = message.to_json
298
305
  EventMachine.next_tick do
299
306
  exchange.publish message, message_options
300
307
  end
@@ -302,44 +309,51 @@ module AlchemyFlux
302
309
 
303
310
  public
304
311
 
305
- # send a message to queue do not wait for response
312
+ # send a message to a service, this does not wait for a response
306
313
  #
307
- # *routing_key*:: The routing key to use
314
+ # *service_name*:: The name of the service
308
315
  # *message*:: The message to be sent
309
- # *options*:: The message options
310
- def send_message_to_queue(routing_key, message)
311
- send_message( @channel.default_exchange, routing_key, message, {type: 'ignore'} )
316
+ def send_message_to_service(service_name, message)
317
+ send_HTTP_message(@channel.default_exchange, service_name, message)
312
318
  end
313
319
 
314
- # send a message to a service
320
+ # send a message to a resource, this does not wait for a response
321
+ #
322
+ # *message*:: HTTP formatted message to be sent, must contain `'path'` key with URL path
323
+ def send_message_to_resource(message)
324
+ routing_key = path_to_routing_key(message['path'])
325
+ send_HTTP_message(@resources_exchange, routing_key, message)
326
+ end
327
+
328
+ # send a request to a service, this will wait for a response
315
329
  #
316
330
  # *service_name*:: the name of the service
317
331
  # *message*:: the message to be sent
318
332
  #
319
333
  # This method can optionally take a block which will be executed asynchronously and yielded the response
320
- def send_message_to_service(service_name, message)
334
+ def send_request_to_service(service_name, message)
321
335
  if block_given?
322
336
  EventMachine.defer do
323
- yield send_message_to_service(service_name, message)
337
+ yield send_request_to_service(service_name, message)
324
338
  end
325
339
  else
326
- send_HTTP_request_message(@channel.default_exchange, service_name, message)
340
+ send_HTTP_request(@channel.default_exchange, service_name, message)
327
341
  end
328
342
  end
329
343
 
330
344
  # send a message to a resource
331
345
  #
332
- # *http_message*:: the message to be sent to the *path* in the message
346
+ # *message*:: HTTP formatted message to be sent, must contain `'path'` key with URL path
333
347
  #
334
348
  # This method can optionally take a block which will be executed asynchronously and yielded the response
335
- def send_message_to_resource(http_message)
336
- routing_key = path_to_routing_key(http_message['path'])
349
+ def send_request_to_resource(message)
350
+ routing_key = path_to_routing_key(message['path'])
337
351
  if block_given?
338
352
  EventMachine.defer do
339
- yield send_message_to_resource(http_message)
353
+ yield send_request_to_resource(message)
340
354
  end
341
355
  else
342
- send_HTTP_request_message(@resources_exchange, routing_key, http_message)
356
+ send_HTTP_request(@resources_exchange, routing_key, message)
343
357
  end
344
358
  end
345
359
 
@@ -363,35 +377,90 @@ module AlchemyFlux
363
377
  new_path
364
378
  end
365
379
 
380
+ # format the HTTP message
381
+ #
382
+ # The entire body is a JSON string with the keys:
383
+ #
384
+ # Request Information:
385
+ #
386
+ # 1. *body*: A string of body information
387
+ # 2. *verb*: The HTTP verb for the query, e.g. GET
388
+ # 3. *headers*: an object with headers in is, e.g. {"X-HEADER-KEY": "value"}
389
+ # 4. *path*: the path of the request, e.g. "/v1/users/1337"
390
+ # 5. *query*: an object with keys for query, e.g. {'search': 'flux'}
391
+ #
392
+ # Call information:
393
+ #
394
+ # 1. *scheme*: the scheme used for the call
395
+ # 2. *host*: the host called to make the call
396
+ # 3. *port*: the port the call was made on
397
+ #
398
+ # Authentication information:
399
+ #
400
+ # 1. *session*: undefined structure that can be passed in the message
401
+ # so that a service does not need to re-authenticate with each message
402
+ #
403
+ def format_HTTP_message(message)
404
+ message = {
405
+ # Request Parameters
406
+ 'body' => message['body'] || "",
407
+ 'verb' => message['verb'] || "GET",
408
+ 'headers' => message['headers'] || {},
409
+ 'path' => message['path'] || "/",
410
+ 'query' => message['query'] || {},
411
+
412
+ # Location
413
+ 'scheme' => message['protocol'] || 'http',
414
+ 'host' => message['hostname'] || 'localhost',
415
+ 'port' => message['port'] || 8080,
416
+
417
+ # Custom Authentication
418
+ 'session' => message['session']
419
+ }
420
+
421
+ message
422
+ end
423
+
366
424
  # send a HTTP message to an exchange with routing key
367
425
  #
368
426
  # *exchange*:: A AMQP exchange
369
427
  # *routing_key*:: The routing key to use
370
428
  # *message*:: The message to be sent
371
- def send_HTTP_request_message(exchange, routing_key, message)
429
+ def send_HTTP_message(exchange, routing_key, message)
430
+ http_message = format_HTTP_message(message)
372
431
 
373
- http_message = {
374
- 'session_id' => message['session_id'],
375
- 'scheme' => message['protocol'] || 'http',
376
- 'host' => message['hostname'] || 'localhost',
377
- 'port' => message['port'] || 8080,
378
- 'path' => message['path'] || "/",
379
- 'query' => message['query'] || {},
380
- 'verb' => message['verb'] || "GET",
381
- 'headers' => message['headers'] || {},
382
- 'body' => message['body'] || ""
432
+ http_message_options = {
433
+ message_id: AlchemyFlux::Service.generateUUID(),
434
+ type: 'http',
435
+ content_encoding: '8bit',
436
+ content_type: 'application/json',
437
+ expiration: @options[:timeout],
438
+ mandatory: true
383
439
  }
384
440
 
441
+ send_message(exchange, routing_key, http_message, http_message_options)
442
+ end
443
+
444
+
445
+
446
+ # send a HTTP message to an exchange with routing key
447
+ #
448
+ # *exchange*:: A AMQP exchange
449
+ # *routing_key*:: The routing key to use
450
+ # *message*:: The message to be sent
451
+ def send_HTTP_request(exchange, routing_key, message)
452
+ http_message = format_HTTP_message(message)
453
+
385
454
  message_id = AlchemyFlux::Service.generateUUID()
386
455
 
387
456
  http_message_options = {
388
457
  message_id: message_id,
389
- type: 'http_request',
458
+ type: 'http',
390
459
  reply_to: @response_queue_name,
391
- content_encoding: '8bit',
392
- content_type: 'application/octet-stream',
393
- expiration: @options[:timeout],
394
- mandatory: true
460
+ content_encoding: '8bit',
461
+ content_type: 'application/json',
462
+ expiration: @options[:timeout],
463
+ mandatory: true
395
464
  }
396
465
 
397
466
  response_queue = Queue.new
@@ -55,6 +55,7 @@ module Rack
55
55
 
56
56
  # add Alchemy Service so the app may call other services
57
57
  rack_env['alchemy.service'] = @@service
58
+ rack_env['alchemy.session'] = message['session']
58
59
 
59
60
  status, headers, body = app.call(rack_env)
60
61
 
@@ -22,7 +22,7 @@ describe "performance of AlchemyFlux" do
22
22
  responses = Queue.new
23
23
  st = Time.now()
24
24
  (1..calls).each do
25
- service_b.send_message_to_service("fluxa.service", {'body' => {'name' => "Bob"}}) do |response|
25
+ service_b.send_request_to_service("fluxa.service", {'body' => {'name' => "Bob"}}) do |response|
26
26
  responses << response
27
27
  end
28
28
  end
@@ -51,7 +51,7 @@ describe "performance of AlchemyFlux" do
51
51
 
52
52
  st = Time.now()
53
53
  (1..calls).each do
54
- resp = service_b.send_message_to_service("fluxa.service", {'body' => {'name' => "Bob"}})
54
+ resp = service_b.send_request_to_service("fluxa.service", {'body' => {'name' => "Bob"}})
55
55
  expect(resp['body']).to eq "hola Bob"
56
56
  end
57
57
 
@@ -19,7 +19,7 @@ describe Rack::Handler::AlchemyFlux do
19
19
  Rack::Handler::AlchemyFlux.start app
20
20
  service_a.start
21
21
  sleep(0.5)
22
- response = service_a.send_message_to_service("rack.service", {})
22
+ response = service_a.send_request_to_service("rack.service", {})
23
23
  expect(response['body']).to eq "hi Bob"
24
24
  service_a.stop
25
25
  Rack::Handler::AlchemyFlux.stop
@@ -38,10 +38,10 @@ describe Rack::Handler::AlchemyFlux do
38
38
  service_a.start
39
39
  sleep(0.5)
40
40
 
41
- response = service_a.send_message_to_resource({'path' => '/alice'})
41
+ response = service_a.send_request_to_resource({'path' => '/alice'})
42
42
  expect(response['body']).to eq "hi /alice"
43
43
 
44
- response = service_a.send_message_to_resource({'path' => '/bob'})
44
+ response = service_a.send_request_to_resource({'path' => '/bob'})
45
45
  expect(response['body']).to eq "hi /bob"
46
46
 
47
47
  service_a.stop
@@ -7,7 +7,7 @@ describe AlchemyFlux::Service do
7
7
  AlchemyFlux::Service.stop
8
8
  end
9
9
 
10
- describe "#send_message_to_resource" do
10
+ describe "#send_request_to_resource" do
11
11
 
12
12
  it 'should be able to send messages to resource via path' do
13
13
  resource_path = "/v1/fluxy_#{AlchemyFlux::Service.generateUUID()}"
@@ -22,10 +22,10 @@ describe AlchemyFlux::Service do
22
22
 
23
23
  sleep(1)
24
24
 
25
- response = service_b.send_message_to_resource({'path' => resource_path, 'body' => {'name' => "Bob"}})
25
+ response = service_b.send_request_to_resource({'path' => resource_path, 'body' => {'name' => "Bob"}})
26
26
  expect(response['body']).to eq "hi Bob"
27
27
 
28
- response = service_b.send_message_to_resource({'path' => "#{resource_path}/id", 'body' => {'name' => "Alice"}})
28
+ response = service_b.send_request_to_resource({'path' => "#{resource_path}/id", 'body' => {'name' => "Alice"}})
29
29
  expect(response['body']).to eq "hi Alice"
30
30
 
31
31
  service_a.stop
@@ -46,10 +46,10 @@ describe AlchemyFlux::Service do
46
46
 
47
47
  sleep(1)
48
48
 
49
- response = service_b.send_message_to_resource({'path' => resource_path1, 'body' => {'name' => "Bob"}})
49
+ response = service_b.send_request_to_resource({'path' => resource_path1, 'body' => {'name' => "Bob"}})
50
50
  expect(response['body']).to eq "hi Bob"
51
51
 
52
- response = service_b.send_message_to_resource({'path' => resource_path2, 'body' => {'name' => "Alice"}})
52
+ response = service_b.send_request_to_resource({'path' => resource_path2, 'body' => {'name' => "Alice"}})
53
53
  expect(response['body']).to eq "hi Alice"
54
54
  service_a.stop
55
55
  service_b.stop
@@ -62,7 +62,7 @@ describe AlchemyFlux::Service do
62
62
 
63
63
  service_b.start
64
64
 
65
- expect(service_b.send_message_to_resource({'path' => '/v1/unregistered_resource'})).to eq AlchemyFlux::MessageNotDeliveredError
65
+ expect(service_b.send_request_to_resource({'path' => '/v1/unregistered_resource'})).to eq AlchemyFlux::MessageNotDeliveredError
66
66
  expect(service_b.transactions.length).to eq 0
67
67
 
68
68
  service_b.stop
@@ -70,4 +70,33 @@ describe AlchemyFlux::Service do
70
70
 
71
71
  end
72
72
  end
73
+
74
+ describe "#send_message_to_resource" do
75
+ it 'should be able to send messages to resource via path' do
76
+ resource_path = "/v1/fluxy_#{AlchemyFlux::Service.generateUUID()}"
77
+ recieved_count = 0
78
+ service_a = AlchemyFlux::Service.new("fluxa.send_service", resource_paths: [resource_path]) do |message|
79
+ recieved_count += 1
80
+ {}
81
+ end
82
+
83
+ service_b = AlchemyFlux::Service.new("fluxb.send_service")
84
+
85
+ service_a.start
86
+ service_b.start
87
+
88
+ sleep(1)
89
+ expect(recieved_count).to be 0
90
+ response = service_b.send_request_to_resource({'path' => resource_path, 'body' => {'name' => "Bob"}})
91
+ sleep(0.1)
92
+ expect(recieved_count).to be 1
93
+ response = service_b.send_request_to_resource({'path' => "#{resource_path}/id", 'body' => {'name' => "Alice"}})
94
+ sleep(0.1)
95
+ expect(recieved_count).to be 2
96
+
97
+ service_a.stop
98
+ service_b.stop
99
+ end
100
+
101
+ end
73
102
  end
@@ -92,7 +92,7 @@ describe AlchemyFlux::Service do
92
92
  service_b.start
93
93
 
94
94
  service_a.stop
95
- expect(service_b.send_message_to_service("fluxa.service", {})).to eq AlchemyFlux::TimeoutError
95
+ expect(service_b.send_request_to_service("fluxa.service", {})).to eq AlchemyFlux::TimeoutError
96
96
  service_b.stop
97
97
  end
98
98
 
@@ -108,7 +108,7 @@ describe AlchemyFlux::Service do
108
108
  service_b.start
109
109
 
110
110
  response_queue = Queue.new
111
- service_b.send_message_to_service("fluxa.service", {}) do |response|
111
+ service_b.send_request_to_service("fluxa.service", {}) do |response|
112
112
  response_queue << response
113
113
  end
114
114
  sleep(0.05)
@@ -132,7 +132,7 @@ describe AlchemyFlux::Service do
132
132
  service_b.start
133
133
 
134
134
  response_queue = Queue.new
135
- service_b.send_message_to_service("fluxa.service", {}) do |response|
135
+ service_b.send_request_to_service("fluxa.service", {}) do |response|
136
136
  response_queue << response
137
137
  end
138
138
  sleep(0.01)
@@ -156,13 +156,13 @@ describe AlchemyFlux::Service do
156
156
  service_b.start
157
157
 
158
158
  response_queue = Queue.new
159
- service_b.send_message_to_service("fluxa.service", {}) do |response|
159
+ service_b.send_request_to_service("fluxa.service", {}) do |response|
160
160
  response_queue << response
161
161
  end
162
162
  sleep(0.1)
163
163
  Thread.new do service_a.stop end
164
164
  sleep(0.3)
165
- expect(service_b.send_message_to_service("fluxa.service", {})).to eq AlchemyFlux::TimeoutError
165
+ expect(service_b.send_request_to_service("fluxa.service", {})).to eq AlchemyFlux::TimeoutError
166
166
 
167
167
  response = response_queue.pop
168
168
 
@@ -180,10 +180,10 @@ describe AlchemyFlux::Service do
180
180
  service_a.start
181
181
  service_b.start
182
182
 
183
- response = service_b.send_message_to_service("fluxa.service", {'body' => {'name' => "Bob"}})
183
+ response = service_b.send_request_to_service("fluxa.service", {'body' => {'name' => "Bob"}})
184
184
  expect(response['body']).to eq "hi Bob"
185
185
 
186
- response = service_a.send_message_to_service("fluxb.service", {'body' => {'name' => "Bob"}})
186
+ response = service_a.send_request_to_service("fluxb.service", {'body' => {'name' => "Bob"}})
187
187
  expect(response['body']).to be_empty
188
188
 
189
189
 
@@ -192,7 +192,8 @@ describe AlchemyFlux::Service do
192
192
  end
193
193
  end
194
194
 
195
- describe "#send_message_to_queue" do
195
+
196
+ describe "#send_message_to_service" do
196
197
  it 'should send a message to services' do
197
198
  received = false
198
199
  service_a = AlchemyFlux::Service.new("fluxa.service") do |message|
@@ -205,7 +206,7 @@ describe AlchemyFlux::Service do
205
206
  service_a.start
206
207
  service_b.start
207
208
 
208
- response = service_b.send_message_to_queue("fluxa.service", {})
209
+ service_b.send_message_to_service("fluxa.service", {})
209
210
  sleep(0.1)
210
211
  expect(received).to be true
211
212
  service_a.stop
@@ -214,7 +215,9 @@ describe AlchemyFlux::Service do
214
215
 
215
216
  end
216
217
 
217
- describe "#send_message_to_service" do
218
+
219
+
220
+ describe "#send_request_to_service" do
218
221
 
219
222
  it 'should send and receive messages between services' do
220
223
  service_a = AlchemyFlux::Service.new("fluxa.service") do |message|
@@ -226,7 +229,7 @@ describe AlchemyFlux::Service do
226
229
  service_a.start
227
230
  service_b.start
228
231
 
229
- response = service_b.send_message_to_service("fluxa.service", {'body' => {'name' => "Bob"}})
232
+ response = service_b.send_request_to_service("fluxa.service", {'body' => {'name' => "Bob"}})
230
233
  expect(response['body']).to eq "hi Bob"
231
234
  service_a.stop
232
235
  service_b.stop
@@ -244,7 +247,7 @@ describe AlchemyFlux::Service do
244
247
  service_a.start
245
248
  service_b.start
246
249
 
247
- response = service_b.send_message_to_service("fluxa.service", {'body' => '{"name" : "Bob"}'})
250
+ response = service_b.send_request_to_service("fluxa.service", {'body' => '{"name" : "Bob"}'})
248
251
  expect(response['body']).to eq "hi Bob"
249
252
  service_a.stop
250
253
  service_b.stop
@@ -264,7 +267,7 @@ describe AlchemyFlux::Service do
264
267
  service_a.start
265
268
  service_b.start
266
269
 
267
- response = service_b.send_message_to_service("fluxa.service", {'body' => '{"name" : "Bob"}'})
270
+ response = service_b.send_request_to_service("fluxa.service", {'body' => '{"name" : "Bob"}'})
268
271
  expect(response['body']).to eq "hi Bob"
269
272
  expect(response['headers']["X-header"]).to eq "header1"
270
273
  service_a.stop
@@ -285,7 +288,7 @@ describe AlchemyFlux::Service do
285
288
  service_a.start
286
289
  service_b.start
287
290
 
288
- response = service_b.send_message_to_service("fluxa.service", {'body' => '{"name" : "Bob"}'})
291
+ response = service_b.send_request_to_service("fluxa.service", {'body' => '{"name" : "Bob"}'})
289
292
  expect(response['body']).to eq "hi Bob"
290
293
  expect(response['status_code']).to eq 201
291
294
  service_a.stop
@@ -294,7 +297,7 @@ describe AlchemyFlux::Service do
294
297
 
295
298
  it 'should be able to send messages within the service call' do
296
299
  service_a = AlchemyFlux::Service.new("fluxa.service") do |message|
297
- resp = service_a.send_message_to_service("fluxb.service", {})
300
+ resp = service_a.send_request_to_service("fluxb.service", {})
298
301
  {'body' => "hi #{resp['body']}"}
299
302
  end
300
303
 
@@ -305,7 +308,7 @@ describe AlchemyFlux::Service do
305
308
  service_a.start
306
309
  service_b.start
307
310
 
308
- response = service_b.send_message_to_service("fluxa.service", {})
311
+ response = service_b.send_request_to_service("fluxa.service", {})
309
312
  expect(response['body']).to eq "hi Bob"
310
313
  service_a.stop
311
314
  service_b.stop
@@ -316,7 +319,7 @@ describe AlchemyFlux::Service do
316
319
  service_a = AlchemyFlux::Service.new("fluxa.service") do |message|
317
320
  if first
318
321
  first = !first
319
- resp = service_a.send_message_to_service("fluxa.service", {})
322
+ resp = service_a.send_request_to_service("fluxa.service", {})
320
323
  {'body' => "hi #{resp['body']}"}
321
324
  else
322
325
  {'body' => 'Bob'}
@@ -328,7 +331,7 @@ describe AlchemyFlux::Service do
328
331
  service_a.start
329
332
  service_b.start
330
333
 
331
- response = service_b.send_message_to_service("fluxa.service", {})
334
+ response = service_b.send_request_to_service("fluxa.service", {})
332
335
  expect(response['body']).to eq "hi Bob"
333
336
  service_a.stop
334
337
  service_b.stop
@@ -351,7 +354,7 @@ describe AlchemyFlux::Service do
351
354
  expect(service_a.processing_messages).to eq 0
352
355
 
353
356
  response = Queue.new
354
- service_b.send_message_to_service("fluxa.service", {}) do |resp|
357
+ service_b.send_request_to_service("fluxa.service", {}) do |resp|
355
358
  response << resp
356
359
  end
357
360
  sleep(0.05)
@@ -378,7 +381,7 @@ describe AlchemyFlux::Service do
378
381
  service_b.start
379
382
 
380
383
  block = Queue.new
381
- service_b.send_message_to_service("fluxa.service", {'body' => {'name' => "Bob"}}) do |response|
384
+ service_b.send_request_to_service("fluxa.service", {'body' => {'name' => "Bob"}}) do |response|
382
385
  block << response
383
386
  end
384
387
 
@@ -404,7 +407,7 @@ describe AlchemyFlux::Service do
404
407
  service_b.start
405
408
 
406
409
  block = Queue.new
407
- service_b.send_message_to_service("fluxa.service", {'body' => {'name' => "Bob"}}) do |response|
410
+ service_b.send_request_to_service("fluxa.service", {'body' => {'name' => "Bob"}}) do |response|
408
411
  block << response
409
412
  end
410
413
  response = block.pop
@@ -425,7 +428,7 @@ describe AlchemyFlux::Service do
425
428
  service_a.start
426
429
  service_b.start
427
430
 
428
- response = service_b.send_message_to_service("fluxa.service", {'body' => {'name' => "Bob"}})
431
+ response = service_b.send_request_to_service("fluxa.service", {'body' => {'name' => "Bob"}})
429
432
 
430
433
  expect(response).to eq AlchemyFlux::TimeoutError
431
434
  expect(service_b.transactions.length).to eq 0
@@ -444,7 +447,7 @@ describe AlchemyFlux::Service do
444
447
  service_a.start
445
448
  service_b.start
446
449
 
447
- response = service_b.send_message_to_service("fluxa.service", {'body' => {'name' => "Bob"}})
450
+ response = service_b.send_request_to_service("fluxa.service", {'body' => {'name' => "Bob"}})
448
451
 
449
452
  expect(response['status_code']).to eq 500
450
453
  expect(service_b.transactions.length).to eq 0
@@ -458,7 +461,7 @@ describe AlchemyFlux::Service do
458
461
 
459
462
  service_b.start
460
463
 
461
- expect(service_b.send_message_to_service("not_a_servoces.service", {})).to eq AlchemyFlux::MessageNotDeliveredError
464
+ expect(service_b.send_request_to_service("not_a_servoces.service", {})).to eq AlchemyFlux::MessageNotDeliveredError
462
465
  expect(service_b.transactions.length).to eq 0
463
466
 
464
467
  service_b.stop
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy-flux
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loyalty New Zealand
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-27 00:00:00.000000000 Z
11
+ date: 2016-02-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -122,20 +122,6 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '2.1'
125
- - !ruby/object:Gem::Dependency
126
- name: msgpack
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '0.7'
132
- type: :runtime
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '0.7'
139
125
  description: Ruby implementation of the Alchemy micro-service framework
140
126
  email:
141
127
  - graham.jenson@loyalty.co.nz
@@ -170,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
156
  version: '0'
171
157
  requirements: []
172
158
  rubyforge_project:
173
- rubygems_version: 2.4.5.1
159
+ rubygems_version: 2.4.8
174
160
  signing_key:
175
161
  specification_version: 4
176
162
  summary: Ruby implementation of the Alchemy micro-service framework