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 +4 -4
- data/README.md +16 -0
- data/lib/resugan/worker/version.rb +1 -1
- data/lib/resugan/worker.rb +17 -1
- data/resugan-worker.gemspec +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ada0d46b0a235c1abf39ac7f977f5e9c31912b1
|
4
|
+
data.tar.gz: ee2c9c6953525bdea273d228406b3dcf31455d92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
data/lib/resugan/worker.rb
CHANGED
@@ -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
|
-
|
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
|
data/resugan-worker.gemspec
CHANGED
@@ -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"
|
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.
|
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-
|
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: '
|
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: '
|
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.
|
125
|
+
rubygems_version: 2.5.1
|
126
126
|
signing_key:
|
127
127
|
specification_version: 4
|
128
128
|
summary: Async worker event dispatcher for resugan
|