resque-worker-timeout 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 057f40e5c369216d00be391532391770a1486b4f
4
+ data.tar.gz: 1332a5195fb23afdf28b316f7959fe5c20932de3
5
+ SHA512:
6
+ metadata.gz: f791a004992b25c73514f347f33ee2771d35de3c88142798b0af7586ef0f945cb8843ad021ed15a262213df80a6148ea4104f9ad61d404cef42bc4df6d27f26b
7
+ data.tar.gz: d1509515ce37476eb7ae8661753a7a8532e3b60ae68fc851be02ad8245305e5de7514579549338e69b92ce16b088a5887166b4d08191ea5b2e15ea12d1bdbe99
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 grant
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,36 @@
1
+ = resque-worker-timeout
2
+
3
+ A Resque plugin. If you want set worker timeout, extend it with this module.
4
+
5
+ == Usage
6
+
7
+ ```ruby
8
+ class TransferFileWorker
9
+ extend Resque::Plugins::WorkerTimeout
10
+
11
+ # 10 minutes (default 10 minutes)
12
+ @timeout = 600
13
+
14
+ # reenqueue worker if timeout happend (default false)
15
+ @reenqueue_worker = true
16
+
17
+ def self.perform(file_name)
18
+ # transfer file
19
+ end
20
+ end
21
+ ```
22
+
23
+ == Contributing to resque-worker-timeout
24
+
25
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
26
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
27
+ * Fork the project.
28
+ * Start a feature/bugfix branch.
29
+ * Commit and push until you are happy with your contribution.
30
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
31
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
32
+
33
+ == Copyright
34
+
35
+ Copyright (c) 2015 grant. See LICENSE.txt for
36
+ further details.
data/Rakefile ADDED
@@ -0,0 +1,51 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
+ gem.name = "resque-worker-timeout"
18
+ gem.homepage = "http://github.com/grant/resque-worker-timeout"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{TODO: one-line summary of your gem}
21
+ gem.description = %Q{TODO: longer description of your gem}
22
+ gem.email = "kucss@hotmail.com"
23
+ gem.authors = ["grant"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ desc "Code coverage detail"
36
+ task :simplecov do
37
+ ENV['COVERAGE'] = "true"
38
+ Rake::Task['test'].execute
39
+ end
40
+
41
+ task :default => :test
42
+
43
+ require 'rdoc/task'
44
+ Rake::RDocTask.new do |rdoc|
45
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
46
+
47
+ rdoc.rdoc_dir = 'rdoc'
48
+ rdoc.title = "resque-worker-timeout #{version}"
49
+ rdoc.rdoc_files.include('README*')
50
+ rdoc.rdoc_files.include('lib/**/*.rb')
51
+ end
@@ -0,0 +1,2 @@
1
+ require 'resque'
2
+ require 'resque/plugins/worker_timeout'
@@ -0,0 +1,28 @@
1
+ module Resque
2
+ module Plugins
3
+ module WorkerTimeout
4
+
5
+ def timeout
6
+ @timeout || 600
7
+ end
8
+
9
+ def reenqueue_worker
10
+ @reenqueue_worker || false
11
+ end
12
+
13
+ def around_perform(*args)
14
+ Timeout::timeout(timeout) do
15
+ begin
16
+ yield
17
+ rescue Timeout::Error => e
18
+ if reloop_worker
19
+ Resque.enqueue self, *args
20
+ else
21
+ raise e
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,34 @@
1
+ require 'simplecov'
2
+
3
+ module SimpleCov::Configuration
4
+ def clean_filters
5
+ @filters = []
6
+ end
7
+ end
8
+
9
+ SimpleCov.configure do
10
+ clean_filters
11
+ load_adapter 'test_frameworks'
12
+ end
13
+
14
+ ENV["COVERAGE"] && SimpleCov.start do
15
+ add_filter "/.rvm/"
16
+ end
17
+ require 'rubygems'
18
+ require 'bundler'
19
+ begin
20
+ Bundler.setup(:default, :development)
21
+ rescue Bundler::BundlerError => e
22
+ $stderr.puts e.message
23
+ $stderr.puts "Run `bundle install` to install missing gems"
24
+ exit e.status_code
25
+ end
26
+ require 'test/unit'
27
+ require 'shoulda'
28
+
29
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
30
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
31
+ require 'resque-worker-timeout'
32
+
33
+ class Test::Unit::TestCase
34
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestResqueWorkerTimeout < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: resque-worker-timeout
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Grant Chen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-16 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |
14
+ A Resque plugin. If you want set worker timeout, extend it with this module.
15
+ For example:
16
+ class TransferFileWorker
17
+ extend Resque::Plugins::WorkerTimeout
18
+
19
+ # 10 minutes (default 10 minutes)
20
+ @timeout = 600
21
+
22
+ # reenqueue worker if timeout happend (default false)
23
+ @reenqueue_worker = true
24
+
25
+ def self.perform(file_name)
26
+ # transfer file
27
+ end
28
+ end
29
+ email: grantcss1982@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - LICENSE.txt
35
+ - README.rdoc
36
+ - Rakefile
37
+ - lib/resque-worker-timeout.rb
38
+ - lib/resque/plugins/worker_timeout.rb
39
+ - test/helper.rb
40
+ - test/test_resque-worker-timeout.rb
41
+ homepage: https://github.com/grantchen/resque-worker-timeout
42
+ licenses: []
43
+ metadata: {}
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 2.4.5
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: A Resque plugin for set worker timeout.
64
+ test_files: []