resque-job_timeout 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## [0.0.1] - 2021-09-12
2
+
3
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,92 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ resque-job_timeout (0.0.1)
5
+ resque (~> 2.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ byebug (11.1.3)
12
+ diff-lcs (1.4.4)
13
+ mono_logger (1.1.1)
14
+ multi_json (1.15.0)
15
+ mustermann (1.1.1)
16
+ ruby2_keywords (~> 0.0.1)
17
+ parallel (1.20.1)
18
+ parser (3.0.2.0)
19
+ ast (~> 2.4.1)
20
+ rack (2.2.3)
21
+ rack-protection (2.1.0)
22
+ rack
23
+ rainbow (3.0.0)
24
+ rake (13.0.6)
25
+ redis (4.4.0)
26
+ redis-namespace (1.8.1)
27
+ redis (>= 3.0.4)
28
+ regexp_parser (2.1.1)
29
+ resque (2.1.0)
30
+ mono_logger (~> 1.0)
31
+ multi_json (~> 1.0)
32
+ redis-namespace (~> 1.6)
33
+ sinatra (>= 0.9.2)
34
+ vegas (~> 0.1.2)
35
+ rexml (3.2.5)
36
+ rspec (3.10.0)
37
+ rspec-core (~> 3.10.0)
38
+ rspec-expectations (~> 3.10.0)
39
+ rspec-mocks (~> 3.10.0)
40
+ rspec-core (3.10.1)
41
+ rspec-support (~> 3.10.0)
42
+ rspec-expectations (3.10.1)
43
+ diff-lcs (>= 1.2.0, < 2.0)
44
+ rspec-support (~> 3.10.0)
45
+ rspec-mocks (3.10.2)
46
+ diff-lcs (>= 1.2.0, < 2.0)
47
+ rspec-support (~> 3.10.0)
48
+ rspec-support (3.10.2)
49
+ rubocop (1.20.0)
50
+ parallel (~> 1.10)
51
+ parser (>= 3.0.0.0)
52
+ rainbow (>= 2.2.2, < 4.0)
53
+ regexp_parser (>= 1.8, < 3.0)
54
+ rexml
55
+ rubocop-ast (>= 1.9.1, < 2.0)
56
+ ruby-progressbar (~> 1.7)
57
+ unicode-display_width (>= 1.4.0, < 3.0)
58
+ rubocop-ast (1.11.0)
59
+ parser (>= 3.0.1.1)
60
+ rubocop-rake (0.6.0)
61
+ rubocop (~> 1.0)
62
+ rubocop-rspec (2.4.0)
63
+ rubocop (~> 1.0)
64
+ rubocop-ast (>= 1.1.0)
65
+ ruby-progressbar (1.11.0)
66
+ ruby2_keywords (0.0.5)
67
+ sinatra (2.1.0)
68
+ mustermann (~> 1.0)
69
+ rack (~> 2.2)
70
+ rack-protection (= 2.1.0)
71
+ tilt (~> 2.0)
72
+ tilt (2.0.10)
73
+ unicode-display_width (2.0.0)
74
+ vegas (0.1.11)
75
+ rack (>= 1.0.0)
76
+
77
+ PLATFORMS
78
+ ruby
79
+ x86_64-darwin-18
80
+ x86_64-linux
81
+
82
+ DEPENDENCIES
83
+ byebug (~> 11)
84
+ rake (~> 13.0)
85
+ resque-job_timeout!
86
+ rspec (~> 3.0)
87
+ rubocop (~> 1.7)
88
+ rubocop-rake (~> 0.6)
89
+ rubocop-rspec (~> 2.0)
90
+
91
+ BUNDLED WITH
92
+ 2.2.22
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Andrea Lorenzetti
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # resque-job_timeout
2
+
3
+ A [Resque](https://github.com/resque/resque) plugin. Requires Resque ~> 2.0.
4
+
5
+ Resque plugin allowing long-running jobs to automatically fail after a specified time.
6
+
7
+ ![main](https://github.com/and9000/resque-job_timeout/actions/workflows/main.yml/badge.svg?branch=main)
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'resque-job_timeout'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle install
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install resque-job_timeout
24
+
25
+ ## Usage
26
+
27
+ Extend your job with this gem.
28
+
29
+ ```ruby
30
+ require 'resque-job_timeout'
31
+
32
+ class ExampleJob
33
+ extend Resque::Plugins::JobTimeout
34
+ @queue = :example_queue
35
+
36
+ def self.perform(*args)
37
+ # magic goes here.
38
+ end
39
+ end
40
+ ```
41
+
42
+ ## Configuration
43
+
44
+ Default timeout is 300 seconds. You can modify it by setting in your configuration
45
+
46
+ ```ruby
47
+ Resque::Plugins::JobTimeout.timeout = 1.hour
48
+ ```
49
+
50
+ ## Development
51
+
52
+ After checking out the repo, run `bundle install` to install dependencies. Then, run `bundle exec rake` to run the tests.
53
+
54
+ ## Contributing
55
+
56
+ Bug reports and pull requests are welcome on GitHub at https://github.com/and9000/resque-job_timeout.
57
+
58
+ ## Credits
59
+
60
+ This gem has been inspired by [resque-timeout](https://github.com/jeffgran/resque-timeout) and [resque-retry](https://github.com/lantins/resque-retry).
61
+
62
+ ## License
63
+
64
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new(:rubocop) do |task|
11
+ task.options = ['--auto-correct-all'] unless ENV['CI'] == 'true'
12
+ end
13
+
14
+ task default: %i[spec rubocop]
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'timeout'
4
+
5
+ module Resque
6
+ module Plugins
7
+ # TODO: document me.
8
+ #
9
+ module JobTimeout
10
+ def self.timeout
11
+ @timeout ||= 300
12
+ end
13
+
14
+ def self.timeout=(timeout)
15
+ @timeout = timeout
16
+ end
17
+
18
+ def around_perform_with_job_timeout(*_args, &block)
19
+ ::Timeout.timeout(Resque::Plugins::JobTimeout.timeout, &block)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Resque
4
+ module JobTimeout
5
+ VERSION = '0.0.1'
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'resque'
4
+
5
+ require_relative 'job_timeout/plugins/job_timeout'
6
+ require_relative 'job_timeout/version'
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/resque/job_timeout/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'resque-job_timeout'
7
+ spec.version = Resque::JobTimeout::VERSION
8
+ spec.authors = ['Andrea Lorenzetti']
9
+ spec.email = ['andrea@lorenzetti.me']
10
+
11
+ spec.summary = 'Resque plugin allowing long-running jobs to automatically fail after a specified time.'
12
+ spec.homepage = 'https://github.com/and9000/resque-job_timeout'
13
+ spec.license = 'MIT'
14
+ spec.required_ruby_version = '>= 2.6'
15
+
16
+ spec.metadata['homepage_uri'] = spec.homepage
17
+ spec.metadata['source_code_uri'] = spec.homepage
18
+ spec.metadata['changelog_uri'] = "#{spec.homepage}/CHANGELOG.md"
19
+
20
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
22
+ end
23
+ spec.require_paths = ['lib']
24
+
25
+ spec.add_dependency 'resque', '~> 2.0'
26
+
27
+ spec.add_development_dependency('byebug', '~> 11')
28
+ spec.add_development_dependency('rake', '~> 13.0')
29
+ spec.add_development_dependency('rspec', '~> 3.0')
30
+ spec.add_development_dependency('rubocop', '~> 1.7')
31
+ spec.add_development_dependency('rubocop-rake', '~> 0.6')
32
+ spec.add_development_dependency('rubocop-rspec', '~> 2.0')
33
+ end
metadata ADDED
@@ -0,0 +1,159 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: resque-job_timeout
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Andrea Lorenzetti
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-09-12 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: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: byebug
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '11'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '13.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '13.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.7'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop-rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.6'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.6'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.0'
111
+ description:
112
+ email:
113
+ - andrea@lorenzetti.me
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".github/workflows/main.yml"
119
+ - ".gitignore"
120
+ - ".rspec"
121
+ - ".rubocop.yml"
122
+ - CHANGELOG.md
123
+ - Gemfile
124
+ - Gemfile.lock
125
+ - LICENSE.txt
126
+ - README.md
127
+ - Rakefile
128
+ - lib/resque/job_timeout.rb
129
+ - lib/resque/job_timeout/plugins/job_timeout.rb
130
+ - lib/resque/job_timeout/version.rb
131
+ - resque-job_timeout.gemspec
132
+ homepage: https://github.com/and9000/resque-job_timeout
133
+ licenses:
134
+ - MIT
135
+ metadata:
136
+ homepage_uri: https://github.com/and9000/resque-job_timeout
137
+ source_code_uri: https://github.com/and9000/resque-job_timeout
138
+ changelog_uri: https://github.com/and9000/resque-job_timeout/CHANGELOG.md
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '2.6'
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ requirements: []
154
+ rubygems_version: 3.2.22
155
+ signing_key:
156
+ specification_version: 4
157
+ summary: Resque plugin allowing long-running jobs to automatically fail after a specified
158
+ time.
159
+ test_files: []