resque-real-serial-queues 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +49 -0
- data/Rakefile +2 -0
- data/lib/.DS_Store +0 -0
- data/lib/resque/.DS_Store +0 -0
- data/lib/resque/plugins/real_serial_queues.rb +47 -0
- data/lib/resque/plugins/version.rb +7 -0
- data/lib/resque_real_serial_queues.rb +1 -0
- data/resque-real-serial-queues.gemspec +25 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f93dfead3f604771c085987d5080ad96e4b89cf9
|
4
|
+
data.tar.gz: 22bd5633ae333f60b33b47c4bd38e6a88a8f784f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: be4ae6f091c52bb056129b7f7a9fa58c04d24533a0d48e49e3233e62359cee5a5e25233554517a522948517648011e099d249a3532de0bf9ee58a8b5bb2547a7
|
7
|
+
data.tar.gz: 23113e249184a5ec4c50a0b67654d95eead593e6bcbb784767524e44665386299f7548aafd69276992e8c06efa9205f1f778ea54fe3689fe4491b382f89c30b8
|
data/.DS_Store
ADDED
Binary file
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 javier
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Resque::Plugins::RealSerialQueues
|
2
|
+
|
3
|
+
This plugin modifies [resque](https://github.com/resque/resque)'s' job reservation process to first check if there is another job
|
4
|
+
from the same queue as the potential job currently being processed by one of your workers and tells the worker to check again after its sleep cycle.
|
5
|
+
|
6
|
+
It is primarily meant to be used to queue long running background jobs across multiple queues in conjunction with something like [resque-scheduler](https://github.com/resque/resque-scheduler)
|
7
|
+
|
8
|
+
A key difference between this and [resque-lonely_job](https://github.com/wallace/resque-lonely_job) is that the queue is not touched when we check to see if we can process the job. However, because we must check all the workers
|
9
|
+
currently working on the system this plugin may not scale well to large numbers of workers.
|
10
|
+
|
11
|
+
This gem is under active development - so please use caution if your jobs are responsible for controlling rocket ships or providing food and shelter to young children.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
gem 'resque-real-serial-queues'
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install resque-real-serial-queues
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
Just load up plugin somewhere in your project's initializers:
|
29
|
+
|
30
|
+
require 'resque_real_serial_queues'
|
31
|
+
|
32
|
+
In rails adding
|
33
|
+
|
34
|
+
resque_real_serial_queues.rb
|
35
|
+
|
36
|
+
to your
|
37
|
+
|
38
|
+
config/initializers
|
39
|
+
|
40
|
+
directory with the above line should do the trick.
|
41
|
+
|
42
|
+
Note that this will currently affect all queues
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
1. Fork it ( https://github.com/[my-github-username]/resque-real-serial-queues/fork )
|
46
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
49
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/lib/.DS_Store
ADDED
Binary file
|
Binary file
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'resque' unless defined?(Resque)
|
2
|
+
|
3
|
+
require "resque/plugins/version"
|
4
|
+
|
5
|
+
# Modifications to resque code go here
|
6
|
+
module Resque
|
7
|
+
class Job
|
8
|
+
|
9
|
+
# Given a queue name and a potential job (the one we are considering popping off the queue)
|
10
|
+
# determine whether there is a worker currently working on a job with the same queue, class, and args
|
11
|
+
# return true if we find an identical job, false if not
|
12
|
+
def self.job_from_same_queue_is_currently_being_run(queue, job)
|
13
|
+
return false unless job
|
14
|
+
|
15
|
+
Worker.working.each do |worker|
|
16
|
+
processing_job = worker.job
|
17
|
+
next unless processing_job
|
18
|
+
|
19
|
+
processing_queue = processing_job['queue']
|
20
|
+
next unless processing_queue
|
21
|
+
|
22
|
+
return true if processing_queue == queue
|
23
|
+
end
|
24
|
+
|
25
|
+
false
|
26
|
+
end
|
27
|
+
|
28
|
+
# Given a string queue name, returns an instance of Resque::Job
|
29
|
+
# if any jobs are available. If not, returns nil.
|
30
|
+
# This is a resque method overridden to first check
|
31
|
+
# if the queue item has an identical job currently being worked on
|
32
|
+
def self.reserve(queue)
|
33
|
+
potential_job = Resque.peek(queue)
|
34
|
+
return if job_from_same_queue_is_currently_being_run(queue, potential_job)
|
35
|
+
return unless payload = Resque.pop(queue)
|
36
|
+
new(queue, payload)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# if we add any actual method extensions add them here
|
42
|
+
module Resque # :nodoc:
|
43
|
+
module Plugins # :nodoc
|
44
|
+
module RealSerialQueues
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'resque/plugins/real_serial_queues'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'resque/plugins/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "resque-real-serial-queues"
|
8
|
+
spec.version = Resque::Plugins::RealSerialQueues::VERSION
|
9
|
+
spec.authors = ["Javier Evans"]
|
10
|
+
spec.email = ["evans.javier@gmail.com"]
|
11
|
+
spec.summary = %q{Resque plugin to allow queues to be processed serially without modifying the queue order}
|
12
|
+
spec.description = %q{The plugin is designed for sequential running of different jobs in the same queue across multiple queues. Specifically meant for running a variety of long-running background tasks scheduled ahead of time using something like reque-scheduler. May not be suitable for large scale operations.}
|
13
|
+
spec.homepage = "https://github.com/4141done/resque-real-serial-queues"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "resque", "~> 1.25"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: resque-real-serial-queues
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Javier Evans
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: resque
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.25'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.25'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: The plugin is designed for sequential running of different jobs in the
|
56
|
+
same queue across multiple queues. Specifically meant for running a variety of
|
57
|
+
long-running background tasks scheduled ahead of time using something like reque-scheduler. May
|
58
|
+
not be suitable for large scale operations.
|
59
|
+
email:
|
60
|
+
- evans.javier@gmail.com
|
61
|
+
executables: []
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- .DS_Store
|
66
|
+
- .gitignore
|
67
|
+
- Gemfile
|
68
|
+
- LICENSE.txt
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- lib/.DS_Store
|
72
|
+
- lib/resque/.DS_Store
|
73
|
+
- lib/resque/plugins/real_serial_queues.rb
|
74
|
+
- lib/resque/plugins/version.rb
|
75
|
+
- lib/resque_real_serial_queues.rb
|
76
|
+
- resque-real-serial-queues.gemspec
|
77
|
+
homepage: https://github.com/4141done/resque-real-serial-queues
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.2.2
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: Resque plugin to allow queues to be processed serially without modifying
|
101
|
+
the queue order
|
102
|
+
test_files: []
|