sidekiq-eventbus 0.0.2 → 0.0.4

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: 08e5b4cf0e6ab67f298d005fe238b18504b83b56
4
- data.tar.gz: 1c333e9f8a673cd70abae2d3a170ecfe57f29350
3
+ metadata.gz: 6cee5a4ecfbeb86566ece98a9d419e008f3b1e82
4
+ data.tar.gz: eb2bbd145e485b05c195b81fa217f3ffd18a452c
5
5
  SHA512:
6
- metadata.gz: 6872239db41e62e1993ce91134adecdba84b6388a52c5ce456ee6e68e12bbd6284418b962c24cfffed9412dde5090ec47b66ef1ad291e7e41db80135a7440724
7
- data.tar.gz: db02caf8fb432a9e88f1e9678304b95a7f0da799d599f6ba4e497267b04e7a49a6869ce472352f560d61c77baefddd94251fcd14c8df9bb2228067fcebd814be
6
+ metadata.gz: 149ea8e9306733ca7777b4e7ace73bd670228e977e567061aeeb1f9d975834c6bc05132c38c0a3ead4e31b2be7acbc5dc2707a32846aa8dfb4d08b431028ca3e
7
+ data.tar.gz: 5136f83e2f4ec1c8f3ff416cf414f96bb60b7e15c6a64b480202e3e094eaa4f68d64f596d025ed94c9b15af8061b88681fb58346b0bc72a63cccd2868d3d84cb
data/README.md CHANGED
@@ -0,0 +1,4 @@
1
+ # sidekiq-eventbus
2
+
3
+ A simple event bus implementation written to offload event handling via Sidekiq.
4
+
@@ -1,5 +1,6 @@
1
1
  class Sidekiq::EventBus::Configuration
2
- attr_accessor :adapter, :consumers, :sidekiq_worker_options
2
+ attr_accessor :adapter, :consumers, :sidekiq_worker_options, :error_handler
3
+
3
4
  def initialize
4
5
  self.adapter = Sidekiq::EventBus::Adapters::Default.new
5
6
  self.consumers = Hash.new { |hash, key| hash[key] = Set.new }
@@ -24,19 +24,19 @@ class Sidekiq::EventBus::Consumer
24
24
 
25
25
 
26
26
  def consume topic, event, payload
27
- _payload = payload.merge('topic'.freeze => topic, 'event'.freeze => event).freeze
27
+ if self.class.handlers.key? event
28
+ _payload = payload.merge('topic'.freeze => topic, 'event'.freeze => event).freeze
28
29
 
29
- self.class.handlers[event].each do |handler|
30
- begin
31
- if handler.is_a? Proc
32
- instance_exec( _payload.dup, &handler )
33
- else
34
- handler.call( _payload.dup )
30
+ self.class.handlers[event].each do |handler|
31
+ begin
32
+ if handler.is_a? Proc
33
+ instance_exec( _payload.dup, &handler )
34
+ else
35
+ handler.call( _payload.dup )
36
+ end
37
+ rescue => e
38
+ Sidekiq::EventBus.utils.handle_error(e)
35
39
  end
36
- rescue => e
37
- puts "OH NO!!!"
38
- puts e.inspect
39
- puts e.backtrace
40
40
  end
41
41
  end
42
42
  end
@@ -1,7 +1,7 @@
1
1
  class Sidekiq::EventBus::Producer
2
2
  attr_reader :topics, :adapter
3
3
 
4
- def initialize topics: nil, adapter: Sidekiq::EventBus.config.adapter
4
+ def initialize topics:, adapter: Sidekiq::EventBus.config.adapter
5
5
  @topics = Array(topics)
6
6
  @adapter = adapter
7
7
  end
@@ -16,4 +16,10 @@ class Sidekiq::EventBus::Utils
16
16
  consumer.consume(topic, event, payload)
17
17
  end
18
18
  end
19
+
20
+ def handle_error exception
21
+ unless config.error_handler.nil?
22
+ config.error_handler.call(exception)
23
+ end
24
+ end
19
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-eventbus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phil Monroe
@@ -9,8 +9,48 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2017-01-21 00:00:00.000000000 Z
12
- dependencies: []
13
- description: A simple Producer/Consumer event bus extension for Sidekiq
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sidekiq
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 4.0.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 4.0.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: rspec
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 3.5.0
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '4.0'
43
+ type: :development
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 3.5.0
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '4.0'
53
+ description: A simple asynchronous Producer/Consumer event bus extension for Sidekiq
14
54
  email: phil@rakefire.io
15
55
  executables: []
16
56
  extensions: []
@@ -54,5 +94,5 @@ rubyforge_project:
54
94
  rubygems_version: 2.5.1
55
95
  signing_key:
56
96
  specification_version: 4
57
- summary: A simple Producer/Consumer event bus extension for Sidekiq
97
+ summary: Producer/Consumer event bus via Sidekiq
58
98
  test_files: []