resugan-worker 0.1.0 → 0.1.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
2
  SHA1:
3
- metadata.gz: 7bcd91a718edb6e2e99b95763dab5ed2e285ade2
4
- data.tar.gz: 4d7a17f6b7ffd87e6327d1a3b4a9dcc630e2d820
3
+ metadata.gz: 5ada0d46b0a235c1abf39ac7f977f5e9c31912b1
4
+ data.tar.gz: ee2c9c6953525bdea273d228406b3dcf31455d92
5
5
  SHA512:
6
- metadata.gz: 532308051fe1f15c73761da10e08fda92a6156d94509005148a53abb125c59b66baead0b0b47fd5145401e99d8e68a35b7f9083e407a120ff4e4492074c1e38b
7
- data.tar.gz: 15874b9ee6796307ce623572e6a537951c2fa636040b503a6aea977f8ee5f537c4803d73ee091daf91ee64304691bdf02390c0ca9e913f2799f1e5bbd5bb203b
6
+ metadata.gz: 09758baa145995bbd5aa223b60e6f709e87900624846afc73f15bc771aa1ff21cd11009865609b8fe162a3b552c6f97a85f383c34b816913e38973be9617d699
7
+ data.tar.gz: d07f73260747c3b8e21f94e85d0cd8ce8f023eb28a73bd873c87b612d53214c1bb7617ad424753e6b317073098df7980af4120ac50447183e4ad735519092596
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Gem Version](https://badge.fury.io/rb/resugan-worker.svg)](https://badge.fury.io/rb/resugan-worker) [![CircleCI](https://circleci.com/gh/jedld/resugan-worker.svg?style=svg)](https://circleci.com/gh/jedld/resugan-worker)
2
+
1
3
  # Resugan::Worker
2
4
 
3
5
  Background worker extension to the resugan gem. Uses redis and parallel_queue
@@ -64,6 +66,20 @@ resugan {
64
66
  }
65
67
  ```
66
68
 
69
+ ## Error and exception handling
70
+
71
+ If you want to handle exceptions showing up in a listener, you can define a handler that gets called
72
+ when something bad happens.
73
+
74
+ ```ruby
75
+ monitor = Resugan::Worker::Monitor.new
76
+ monitor.configure do |config|
77
+ config.error_handler = ->(namespace, event, args, exception) {
78
+ puts exception.backtrace
79
+ }
80
+ end
81
+ ```
82
+
67
83
  ## Development
68
84
 
69
85
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,5 +1,5 @@
1
1
  module Resugan
2
2
  module Worker
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -7,12 +7,22 @@ require "json"
7
7
 
8
8
  module Resugan
9
9
  module Worker
10
+ class Config
11
+ attr_accessor :error_handler
12
+ end
13
+
10
14
  class Monitor
11
15
  def initialize(namespace = '')
12
16
  @namespace = namespace
17
+ @config = Config.new
13
18
  @queue = ParallelQueue.new(redis, 'resugan_queue-' + namespace)
14
19
  end
15
20
 
21
+ def configure(&block)
22
+ block.call(@config)
23
+ self
24
+ end
25
+
16
26
  def start
17
27
  puts "monitoring resugan queue: #{@namespace}"
18
28
 
@@ -40,7 +50,13 @@ module Resugan
40
50
  event = unmarshalled_event["event"]
41
51
  args = unmarshalled_event["args"]
42
52
 
43
- Resugan::Kernel.invoke(@namespace, event, args)
53
+ begin
54
+ Resugan::Kernel.invoke(@namespace, event, args)
55
+ rescue StandardError => exception
56
+ if @config.error_handler
57
+ @config.error_handler.call(@namespace, event, args, exception)
58
+ end
59
+ end
44
60
  end
45
61
  end
46
62
  end
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
29
 
30
- spec.add_development_dependency "bundler", "~> 1.12"
30
+ spec.add_development_dependency "bundler"
31
31
  spec.add_development_dependency "rake", "~> 10.0"
32
32
  spec.add_development_dependency "rspec", "~> 3.0"
33
33
  spec.add_dependency "resugan", "~> 0.1"
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resugan-worker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Emmanuel Dayo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-28 00:00:00.000000000 Z
11
+ date: 2016-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.12'
19
+ version: '0'
20
20
  type: :development
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.12'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  version: '0'
123
123
  requirements: []
124
124
  rubyforge_project:
125
- rubygems_version: 2.4.5.1
125
+ rubygems_version: 2.5.1
126
126
  signing_key:
127
127
  specification_version: 4
128
128
  summary: Async worker event dispatcher for resugan