superbolt 0.5.1 → 0.5.2

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: 10cf14224cd0251f4bb5e981d0a8795e42f93cce
4
- data.tar.gz: 830da86d9ebd337a47bd56be66cbe5771673a50b
3
+ metadata.gz: 968ca2d1026ac1b168a119f49a57c5f5c5bbf107
4
+ data.tar.gz: b8c817960cf0a1d73ace5eb4068eb35af4fb18b5
5
5
  SHA512:
6
- metadata.gz: 4b40a2d370fc2cbb28940734c2fb4a8d29993325dccc5fbee26943948dc6eaa1384135880ecb469b124e0533006a60cb62028f89625f892001d874deb4493035
7
- data.tar.gz: 28dce44be96f3072e02ce1874f303ce9b1d938332925a42378032047a5fb9b35b9fdccf56738ed9247f1a98b164de1bca475695ac86738f502c1889fb680718e
6
+ metadata.gz: ebad807328b0aaa33ca84477e517fc9c4655709a942d3143ac2563c38b4d6fe83729394b6365b1d8174c0a1cd1a4ca67b8757f8ef1aab7c9f8ce74f8f0dc9934
7
+ data.tar.gz: b37936716e7266e02c914a76c9eeb3a4da53059cacd62ea7b8d635a1098620c09a4e984abe0964b88623c6566d393e2b2fbb20ae02de8ec08713462798d7a8ce
data/Rakefile CHANGED
@@ -1 +1,23 @@
1
1
  require "bundler/gem_tasks"
2
+ require "superbolt/tasks"
3
+
4
+
5
+ # This one is for locally testing your crazy ideas
6
+ task :environment do
7
+ class MySleeperCell < Superbolt::MessageHandler
8
+ def perform
9
+ sleep(rand(10))
10
+ end
11
+ end
12
+
13
+ Superbolt.config = {
14
+ connection_params: {
15
+ host: '127.0.0.1',
16
+ heartbeat: 1,
17
+ }
18
+ }
19
+ Superbolt.app_name = 'food'
20
+ Superbolt::Router.routes = {
21
+ 'do-it' => 'MySleeperCell'
22
+ }
23
+ end
@@ -12,12 +12,21 @@ module Superbolt
12
12
 
13
13
  def subscribe
14
14
  queue.subscribe(ack: ack) do |metadata, payload|
15
- message = IncomingMessage.new(metadata, payload, channel)
16
- processor = Processor.new(message, logger, &block)
17
- unless processor.perform
18
- on_error(message.parse, processor.exception)
15
+ #Thanks again to LShift for this solution to long-running processes
16
+ #Defer keeps heartbeat running while the process finishes
17
+ EM.defer do
18
+ # this gets run on the thread pool
19
+ message = Superbolt::IncomingMessage.new(metadata, payload, channel)
20
+ processor = Superbolt::Processor.new(message, logger, &block)
21
+ unless processor.perform
22
+ on_error(message.parse, processor.exception)
23
+ end
24
+
25
+ EM.next_tick do
26
+ # this gets run back on the main loop
27
+ message.ack if ack
28
+ end
19
29
  end
20
- message.ack if ack
21
30
  end
22
31
  end
23
32
 
@@ -1,3 +1,3 @@
1
1
  module Superbolt
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
@@ -0,0 +1,9 @@
1
+ module EM
2
+ def self.defer(&block)
3
+ block.call
4
+ end
5
+
6
+ def self.next_tick(&block)
7
+ block.call
8
+ end
9
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: superbolt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - socialchorus
@@ -176,6 +176,7 @@ files:
176
176
  - spec/spec_helper.rb
177
177
  - spec/superbolt_spec.rb
178
178
  - spec/support/commodore.jpg
179
+ - spec/support/em_mocking.rb
179
180
  - spec/support/queue_helpers.rb
180
181
  - superbolt.gemspec
181
182
  homepage: ''
@@ -215,4 +216,5 @@ test_files:
215
216
  - spec/spec_helper.rb
216
217
  - spec/superbolt_spec.rb
217
218
  - spec/support/commodore.jpg
219
+ - spec/support/em_mocking.rb
218
220
  - spec/support/queue_helpers.rb