alchemy-flux 1.2.0 → 1.2.1

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
- SHA1:
3
- metadata.gz: 0e3adb87ffd4968f7ae069194f695b67565a7067
4
- data.tar.gz: 540bc0d0a085ac214f3acbd4cdbffee0b3154f3f
2
+ SHA256:
3
+ metadata.gz: f2af2e1237e1850ba489e4f21b0ae0d5add41255524202ac5e0038cea1617022
4
+ data.tar.gz: 3c230340dc2046305ebb0e2c5c3cbf39b3a7542ffc56345654f91f5bf2193a06
5
5
  SHA512:
6
- metadata.gz: 83e835f3a87903f1a854d66ee21e6714c9a2877384e8ef04a3f69347cfdf2680249ac3f22ecc0c1a002c38d79458bcb442b502ac7cde17c9b4c7560fc6a3de9a
7
- data.tar.gz: 3ac0b6d8b289034f1efa88a643399ffd129c98f5ab07e267e120ea1560cbdd33603ef8e90980e266badb4e0fc0e0895dafc614197f978590dd104c4d5c592b3e
6
+ metadata.gz: 8bac74771bc6dcc6689054b855dbfa9f76becdb6c03a55eae950a1b263ae4a226269d335ac8ff7d96d1e5573c392c24d3bbea2d7c4f6077eaffb5e7a60649a54
7
+ data.tar.gz: 82ab251f97feb72239ba678de72ee705476ba0979f47170cbca1560af368c91f8486b05fc0837b95e84bc45299fdf562daab6b96b1c0cf3e9aa8a35872ca3b35
data/lib/alchemy-flux.rb CHANGED
@@ -228,22 +228,7 @@ module AlchemyFlux
228
228
  rescue AlchemyFlux::NAckError => e
229
229
  AlchemyFlux::NAckError
230
230
  rescue Exception => e
231
- puts "Service Fn Error " + e.inspect
232
-
233
- {
234
- 'status_code' => 500,
235
- 'headers' => {'Content-Type' => 'application/json; charset=utf-8'},
236
- 'body' => {
237
- 'kind' => "Errors",
238
- 'id' => AlchemyFlux::Service.generateUUID(),
239
- 'created_at' => Time.now.utc.iso8601,
240
- 'errors' => [{
241
- 'code' => 'alchemy-flux.error',
242
- 'message' => 'An unexpected error occurred',
243
- 'message_id' => message_replying_to
244
- }]
245
- }
246
- }
231
+ e
247
232
  end
248
233
  }
249
234
 
@@ -251,6 +236,10 @@ module AlchemyFlux
251
236
 
252
237
  if result == AlchemyFlux::NAckError
253
238
  @service_queue.reject(delivery_tag)
239
+ elsif result.is_a?(Exception)
240
+ # if there is an unhandled exception from the service,
241
+ # raise it to force exit and container management can spin up a new one
242
+ raise result
254
243
  else
255
244
  #if there is a service to reply to then reply, else ignore
256
245
 
@@ -6,10 +6,10 @@ module AlchemyFlux
6
6
 
7
7
  # Version of the gem, read into 'alchemy-flux.gemspec'.
8
8
  #
9
- VERSION = '1.2.0'
9
+ VERSION = '1.2.1'
10
10
 
11
11
  # Date of the above VERSION, read into 'alchemy-flux.gemspec'.
12
12
  #
13
- DATE = '2017-08-04'
13
+ DATE = '2018-05-08'
14
14
 
15
15
  end
data/spec/service_spec.rb CHANGED
@@ -417,39 +417,36 @@ describe AlchemyFlux::Service do
417
417
  service_b.stop
418
418
  end
419
419
 
420
- it 'should timeout if a message takes too long' do
420
+ it 'should raise exception if service_fn raises an error' do
421
421
  service_a = AlchemyFlux::Service.new("fluxa.service") do |message|
422
- sleep(0.1)
423
- {}
422
+ raise "An unexpected exception!"
424
423
  end
425
424
 
426
- service_b = AlchemyFlux::Service.new("fluxb.service", timeout: 100)
425
+ service_b = AlchemyFlux::Service.new("fluxb.service")
427
426
 
428
427
  service_a.start
429
428
  service_b.start
430
429
 
431
- response = service_b.send_request_to_service("fluxa.service", {'body' => {'name' => "Bob"}})
432
-
433
- expect(response).to eq AlchemyFlux::TimeoutError
434
- expect(service_b.transactions.length).to eq 0
430
+ expect { service_b.send_request_to_service("fluxa.service", {'body' => {'name' => "Bob"}}) }.to raise_error(RuntimeError)
435
431
 
436
432
  service_a.stop
437
433
  service_b.stop
438
434
  end
439
435
 
440
- it 'should 500 if service_fn raises an error' do
436
+ it 'should timeout if a message takes too long' do
441
437
  service_a = AlchemyFlux::Service.new("fluxa.service") do |message|
442
- raise Error.new
438
+ sleep(0.1)
439
+ {}
443
440
  end
444
441
 
445
- service_b = AlchemyFlux::Service.new("fluxb.service")
442
+ service_b = AlchemyFlux::Service.new("fluxb.service", timeout: 100)
446
443
 
447
444
  service_a.start
448
445
  service_b.start
449
446
 
450
447
  response = service_b.send_request_to_service("fluxa.service", {'body' => {'name' => "Bob"}})
451
448
 
452
- expect(response['status_code']).to eq 500
449
+ expect(response).to eq AlchemyFlux::TimeoutError
453
450
  expect(service_b.transactions.length).to eq 0
454
451
 
455
452
  service_a.stop
@@ -469,4 +466,4 @@ describe AlchemyFlux::Service do
469
466
 
470
467
  end
471
468
  end
472
- end
469
+ end
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: 1.2.0
4
+ version: 1.2.1
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: 2017-08-04 00:00:00.000000000 Z
11
+ date: 2018-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
157
  version: '0'
158
158
  requirements: []
159
159
  rubyforge_project:
160
- rubygems_version: 2.4.5
160
+ rubygems_version: 2.7.6
161
161
  signing_key:
162
162
  specification_version: 4
163
163
  summary: Ruby implementation of the Alchemy micro-service framework