resque-jobs-per-fork 0.5.0 → 1.15.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +3 -1
- data/lib/resque-jobs-per-fork.rb +5 -5
- metadata +14 -14
data/README.rdoc
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
= resque-jobs-per-fork
|
2
2
|
|
3
3
|
If you have very frequent and fast resque jobs, the overhead of forking and running your after_fork hook, might get too big. Using this resque plugin, you can have your workers perform more than one job, before terminating.
|
4
|
+
The original use case for this project was keeping connections while fetching data from a very fragile and crappy webservice.
|
4
5
|
|
5
6
|
You simply specify the number of jobs you want each fork to run using the JOBS_PER_FORK environment variable:
|
6
7
|
|
@@ -15,11 +16,12 @@ This plugin also defines 2 new hooks that get called after the fork starts and b
|
|
15
16
|
Resque.before_perform_jobs_per_fork do |worker|
|
16
17
|
worker.log("Your message here")
|
17
18
|
end
|
18
|
-
|
19
|
+
|
19
20
|
Resque.after_perform_jobs_per_fork do |worker|
|
20
21
|
worker.log("Your message here")
|
21
22
|
end
|
22
23
|
|
24
|
+
Version 1.15.x works on Resque 1.15.x
|
23
25
|
Version 0.5.x works on Resque 1.11.x
|
24
26
|
Version 0.4.x works on Resque 1.10.x
|
25
27
|
Version 0.3.x works on Resque 1.8.x
|
data/lib/resque-jobs-per-fork.rb
CHANGED
@@ -3,7 +3,7 @@ require 'resque/worker'
|
|
3
3
|
|
4
4
|
|
5
5
|
module Resque
|
6
|
-
|
6
|
+
|
7
7
|
# the `before_perform_jobs_per_fork` hook will run in the child perform
|
8
8
|
# right before the child perform starts
|
9
9
|
#
|
@@ -17,7 +17,7 @@ module Resque
|
|
17
17
|
def self.before_perform_jobs_per_fork=(before_perform_jobs_per_fork)
|
18
18
|
@before_perform_jobs_per_fork = before_perform_jobs_per_fork
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
# the `after_perform_jobs_per_fork` hook will run in the child perform
|
22
22
|
# right before the child perform terminates
|
23
23
|
#
|
@@ -26,14 +26,14 @@ module Resque
|
|
26
26
|
def self.after_perform_jobs_per_fork(&block)
|
27
27
|
block ? (@after_perform_jobs_per_fork = block) : @after_perform_jobs_per_fork
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
# Set the after_perform_jobs_per_fork proc.
|
31
31
|
def self.after_perform_jobs_per_fork=(after_perform_jobs_per_fork)
|
32
32
|
@after_perform_jobs_per_fork = after_perform_jobs_per_fork
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
class Worker
|
36
|
-
|
36
|
+
|
37
37
|
def perform_with_jobs_per_fork(job)
|
38
38
|
raise "You need to set JOBS_PER_FORK on the command line" unless ENV['JOBS_PER_FORK']
|
39
39
|
run_hook :before_perform_jobs_per_fork, self
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-jobs-per-fork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 41
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
|
-
-
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version:
|
7
|
+
- 1
|
8
|
+
- 15
|
9
|
+
- 1
|
10
|
+
version: 1.15.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sam Granieri
|
@@ -16,23 +16,23 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-05-09 00:00:00 -05:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
|
-
|
24
|
-
type: :runtime
|
25
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
26
24
|
none: false
|
27
25
|
requirements:
|
28
26
|
- - ~>
|
29
27
|
- !ruby/object:Gem::Version
|
30
|
-
hash:
|
28
|
+
hash: 17
|
31
29
|
segments:
|
32
30
|
- 1
|
33
|
-
-
|
34
|
-
version: "1.
|
35
|
-
|
31
|
+
- 15
|
32
|
+
version: "1.15"
|
33
|
+
prerelease: false
|
34
|
+
type: :runtime
|
35
|
+
requirement: *id001
|
36
36
|
name: resque
|
37
37
|
description: When your resque jobs are frequent and fast, the overhead of forking and running your after_fork might get too big.
|
38
38
|
email:
|
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
80
|
requirements: []
|
81
81
|
|
82
82
|
rubyforge_project:
|
83
|
-
rubygems_version: 1.
|
83
|
+
rubygems_version: 1.6.2
|
84
84
|
signing_key:
|
85
85
|
specification_version: 3
|
86
86
|
summary: Have your resque workers process more that one job
|