rabbit_jobs 0.5.8 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  module RabbitJobs
4
- VERSION = "0.5.8"
4
+ VERSION = "0.5.9"
5
5
  end
@@ -101,15 +101,20 @@ module RabbitJobs
101
101
 
102
102
  RJ.logger.info "Subscribing to #{queue_name(routing_key)}"
103
103
  queue.subscribe(ack: explicit_ack) do |metadata, payload|
104
- begin
105
- processed_count += 1 if process_message(metadata, payload)
106
- rescue
107
- RJ.logger.warn "process_message failed. payload: #{payload.inspect}"
108
- RJ.logger.warn $!.inspect
109
- $!.backtrace.each {|l| RJ.logger.warn l}
104
+ if RJ.run_before_process_message_callbacks
105
+ begin
106
+ processed_count += 1 if process_message(metadata, payload)
107
+ rescue
108
+ RJ.logger.warn "process_message failed. payload: #{payload.inspect}"
109
+ RJ.logger.warn $!.inspect
110
+ $!.backtrace.each {|l| RJ.logger.warn l}
111
+ end
112
+ metadata.ack if explicit_ack
113
+ else
114
+ RJ.logger.warn "before_process_message hook failed, requeuing payload: #{payload.inspect}"
115
+ metadata.reject(requeue: true) if explicit_ack
110
116
  end
111
117
 
112
- metadata.ack if explicit_ack
113
118
  check_shutdown.call
114
119
  end
115
120
  }
data/lib/rabbit_jobs.rb CHANGED
@@ -134,6 +134,21 @@ module RabbitJobs
134
134
  callback.call
135
135
  }
136
136
  end
137
+
138
+ def before_process_message(&block)
139
+ raise unless block_given?
140
+ @before_process_message_callbacks ||= []
141
+ @before_process_message_callbacks << block
142
+ end
143
+
144
+ def run_before_process_message_callbacks
145
+ @before_process_message_callbacks ||= []
146
+ @before_process_message_callbacks.each { |callback|
147
+ return false unless callback.call
148
+ }
149
+ return true
150
+ end
151
+
137
152
  end
138
153
 
139
- RJ = RabbitJobs
154
+ RJ = RabbitJobs
metadata CHANGED
@@ -1,71 +1,60 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rabbit_jobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.8
4
+ version: 0.5.9
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Pavel Lazureykis
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-03-05 00:00:00.000000000 Z
12
+ date: 2013-03-06 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: amqp
15
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &21322560 !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
19
21
  version: '0.9'
20
22
  type: :runtime
21
23
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ~>
25
- - !ruby/object:Gem::Version
26
- version: '0.9'
24
+ version_requirements: *21322560
27
25
  - !ruby/object:Gem::Dependency
28
26
  name: rake
29
- requirement: !ruby/object:Gem::Requirement
27
+ requirement: &21321760 !ruby/object:Gem::Requirement
28
+ none: false
30
29
  requirements:
31
- - - '>='
30
+ - - ! '>='
32
31
  - !ruby/object:Gem::Version
33
32
  version: '0'
34
33
  type: :runtime
35
34
  prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '>='
39
- - !ruby/object:Gem::Version
40
- version: '0'
35
+ version_requirements: *21321760
41
36
  - !ruby/object:Gem::Dependency
42
37
  name: rufus-scheduler
43
- requirement: !ruby/object:Gem::Requirement
38
+ requirement: &21344180 !ruby/object:Gem::Requirement
39
+ none: false
44
40
  requirements:
45
41
  - - ~>
46
42
  - !ruby/object:Gem::Version
47
43
  version: '2.0'
48
44
  type: :runtime
49
45
  prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ~>
53
- - !ruby/object:Gem::Version
54
- version: '2.0'
46
+ version_requirements: *21344180
55
47
  - !ruby/object:Gem::Dependency
56
48
  name: rails
57
- requirement: !ruby/object:Gem::Requirement
49
+ requirement: &21342820 !ruby/object:Gem::Requirement
50
+ none: false
58
51
  requirements:
59
- - - '>='
52
+ - - ! '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '3.0'
62
55
  type: :runtime
63
56
  prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - '>='
67
- - !ruby/object:Gem::Version
68
- version: '3.0'
57
+ version_requirements: *21342820
69
58
  description: Background jobs on RabbitMQ
70
59
  email:
71
60
  - lazureykis@gmail.com
@@ -114,37 +103,32 @@ files:
114
103
  - spec/unit/worker_spec.rb
115
104
  homepage: ''
116
105
  licenses: []
117
- metadata: {}
118
106
  post_install_message:
119
107
  rdoc_options: []
120
108
  require_paths:
121
109
  - lib
122
110
  required_ruby_version: !ruby/object:Gem::Requirement
111
+ none: false
123
112
  requirements:
124
- - - '>='
113
+ - - ! '>='
125
114
  - !ruby/object:Gem::Version
126
115
  version: '0'
116
+ segments:
117
+ - 0
118
+ hash: -3368029020513030695
127
119
  required_rubygems_version: !ruby/object:Gem::Requirement
120
+ none: false
128
121
  requirements:
129
- - - '>='
122
+ - - ! '>='
130
123
  - !ruby/object:Gem::Version
131
124
  version: '0'
125
+ segments:
126
+ - 0
127
+ hash: -3368029020513030695
132
128
  requirements: []
133
129
  rubyforge_project:
134
- rubygems_version: 2.0.0
130
+ rubygems_version: 1.8.11
135
131
  signing_key:
136
- specification_version: 4
132
+ specification_version: 3
137
133
  summary: Background jobs on RabbitMQ
138
- test_files:
139
- - spec/fixtures/config.yml
140
- - spec/fixtures/jobs.rb
141
- - spec/fixtures/schedule.yml
142
- - spec/integration/publisher_spec.rb
143
- - spec/integration/scheduler_spec.rb
144
- - spec/integration/worker_spec.rb
145
- - spec/spec_helper.rb
146
- - spec/unit/configuration_spec.rb
147
- - spec/unit/job_spec.rb
148
- - spec/unit/mailer_spec.rb
149
- - spec/unit/rabbit_jobs_spec.rb
150
- - spec/unit/worker_spec.rb
134
+ test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 439e03e7637f31181be227c61ab20642475358ec
4
- data.tar.gz: 50ec4db3e760511ea91fb77bd9000c303a6dbec3
5
- SHA512:
6
- metadata.gz: 1ee2c38bb0dc8a53c05c629a9e71a29d81aab930aa4495c3d7c4747444813e6e42efa0a2d22e12629f4f79b38bfcb2fcf3142c070033b991786e9119fe43afac
7
- data.tar.gz: 2c208cb4c17727b2f3662528a8f6364b5d3852e0d51f0c0a52e384081363ecd63bcfe53dd4b6c379571567e97c9fa981e63f9922d8383266fe888f7ac82e6c97