execution_deadline 0.1.0
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/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +207 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/execution_deadline.gemspec +28 -0
- data/lib/execution_deadline/deadline.rb +33 -0
- data/lib/execution_deadline/errors.rb +7 -0
- data/lib/execution_deadline/helpers.rb +75 -0
- data/lib/execution_deadline/version.rb +3 -0
- data/lib/execution_deadline.rb +23 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8db051c4e993ec213f306abdbd5bc2b040ee54a1deaf2dd3e792499bd7df2281
|
4
|
+
data.tar.gz: 51f845449e648ff5194b80e03c99e38678c483da9b3f7768d3c839010870034a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 557fcc632853b4d9f36ade03025724900060e2c6a2469f0d53f71f5f1184d455a87f21d77bd7409577c265ebe0349ff83e2826dcbe8c3849a5cb1943eb003101
|
7
|
+
data.tar.gz: d8daf31b451a24e88a69854a32fb29a852932cba06a191ab98c03cd3e539145f238a4a2823e90d1a9ef400678cd3fd9358abbffdbd6b962ffc9783a2895dbbe3
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at bmalinconico@terminus.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Brian Malinconico
|
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,207 @@
|
|
1
|
+
# ExecutionDeadline
|
2
|
+
|
3
|
+
Odds are, you should never ever, ever, use Ruby's built in timeout module
|
4
|
+
unless you are 100% certain the wrapped code may be interrupted at any point.
|
5
|
+
This gem provides a way to easily identify safe breakpoints for timeout
|
6
|
+
operations.
|
7
|
+
|
8
|
+
Usage of this gem should be combined with [the-ultimate-guide-to-ruby-timeouts](https://github.com/ankane/the-ultimate-guide-to-ruby-timeouts)
|
9
|
+
to ensure your application releases resources from otherwise stuck threads.
|
10
|
+
|
11
|
+
## Why use deadlines?
|
12
|
+
[gRPC and Deadlines](https://grpc.io/blog/deadlines/)
|
13
|
+
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
Add this line to your application's Gemfile:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem 'execution_deadline'
|
21
|
+
```
|
22
|
+
|
23
|
+
And then execute:
|
24
|
+
|
25
|
+
$ bundle
|
26
|
+
|
27
|
+
Or install it yourself as:
|
28
|
+
|
29
|
+
$ gem install execution_deadline
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
### Deadline Enforcement
|
34
|
+
|
35
|
+
Deadlines are enforced only at breakpoints in the code specifically marked as
|
36
|
+
safe to error. This is most easily done with the simple method wrappers
|
37
|
+
provided in ExecutionDeadline::Helpers.
|
38
|
+
|
39
|
+
#### Examples
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
class SlowClass
|
43
|
+
extend ExecutionDeadline::Helpers
|
44
|
+
|
45
|
+
deadline in: 1
|
46
|
+
def perform
|
47
|
+
sub_method_1
|
48
|
+
sub_method_1
|
49
|
+
method_never_called
|
50
|
+
end
|
51
|
+
|
52
|
+
deadline runs_for: 0.6
|
53
|
+
def sub_method_1
|
54
|
+
sleep 0.7
|
55
|
+
end
|
56
|
+
|
57
|
+
def method_never_called; end
|
58
|
+
end
|
59
|
+
|
60
|
+
instance = SlowClass.new
|
61
|
+
instance.perform # Throws OutOfTime error since sub_method_1 takes 0.6s of
|
62
|
+
# the total allowed 1s execution time. Since only 0.4s
|
63
|
+
# is left, the second execution of sub_method_1 is prevented
|
64
|
+
```
|
65
|
+
|
66
|
+
When calculating time left after the execution of a method the actual execution
|
67
|
+
time of the method is used. Consider the above example, but with a shorter
|
68
|
+
actual execution time.
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
class ThinksItsSlowClass
|
72
|
+
extend ExecutionDeadline::Helpers
|
73
|
+
|
74
|
+
deadline in: 1
|
75
|
+
def perform
|
76
|
+
sub_method_1
|
77
|
+
sub_method_1
|
78
|
+
method_never_called
|
79
|
+
end
|
80
|
+
|
81
|
+
deadline runs_for: 0.6
|
82
|
+
def sub_method_1
|
83
|
+
sleep 0.1
|
84
|
+
end
|
85
|
+
|
86
|
+
def method_is_called
|
87
|
+
:abcd
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
instance = SlowClass.new
|
92
|
+
instance.perform # No errors are thrown and :abcd returned. Even though
|
93
|
+
# sub_method_1 says it will take 0.6 seconds, it actually
|
94
|
+
# takes 0.1 seconds. The second execution of sub_method_1 is
|
95
|
+
# checked against the remaining 0.9s, and allowed to continue
|
96
|
+
```
|
97
|
+
|
98
|
+
Deadlines are also usable on class methods and module methods.
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
class SlowClass
|
102
|
+
extend ExecutionDeadline::Helpers
|
103
|
+
|
104
|
+
deadline in: 1
|
105
|
+
def self.perform
|
106
|
+
sub_method_1
|
107
|
+
sub_method_1
|
108
|
+
method_never_called
|
109
|
+
end
|
110
|
+
|
111
|
+
deadline runs_for: 0.6
|
112
|
+
def self.sub_method_1
|
113
|
+
sleep 0.7
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.method_never_called; end
|
117
|
+
end
|
118
|
+
|
119
|
+
SlowClass..perform # Throws OutOfTime error
|
120
|
+
|
121
|
+
module SlowModule
|
122
|
+
extend ExecutionDeadline::Helpers
|
123
|
+
|
124
|
+
deadline in: 1
|
125
|
+
def self.perform
|
126
|
+
sub_method_1
|
127
|
+
sub_method_1
|
128
|
+
method_never_called
|
129
|
+
end
|
130
|
+
|
131
|
+
deadline runs_for: 0.6
|
132
|
+
def self.sub_method_1
|
133
|
+
sleep 0.7
|
134
|
+
end
|
135
|
+
|
136
|
+
def self.method_never_called; end
|
137
|
+
end
|
138
|
+
|
139
|
+
SlowModule.perform # Throws OutOfTime error
|
140
|
+
```
|
141
|
+
|
142
|
+
### Raised Errors
|
143
|
+
`ExecutionDeadline::OutOfTime` - Raised when a deadlined method is called but
|
144
|
+
there is less time left then the expected runtime.
|
145
|
+
|
146
|
+
`ExecutionDeadline::DeadlineExceeded` - Raised when a deadlined method is
|
147
|
+
and completed after the deadline time has passed.
|
148
|
+
|
149
|
+
All errors are subclasses of `ExecutionDeadline::DeadlineError`
|
150
|
+
|
151
|
+
#### Customizing Errors
|
152
|
+
|
153
|
+
The errors raised may be customized using the `raises` keyword. The error to be
|
154
|
+
raised may _only_ be set when the deadline is defined (using the `in` keyword)
|
155
|
+
|
156
|
+
```ruby
|
157
|
+
module SlowModule
|
158
|
+
class CustomError < StandardError; end
|
159
|
+
extend ExecutionDeadline::Helpers
|
160
|
+
|
161
|
+
deadline in: 1, raises: CustomError
|
162
|
+
def self.runs_out_of_time
|
163
|
+
sub_method_1
|
164
|
+
sub_method_1
|
165
|
+
method_never_called
|
166
|
+
end
|
167
|
+
|
168
|
+
deadline runs_for: 0.6
|
169
|
+
def self.sub_method_1
|
170
|
+
sleep 0.8
|
171
|
+
end
|
172
|
+
|
173
|
+
deadline in: 1, raises: CustomError
|
174
|
+
def self.runs_over_time
|
175
|
+
runs_over
|
176
|
+
method_never_called
|
177
|
+
end
|
178
|
+
|
179
|
+
deadline runs_for: 0.5
|
180
|
+
def self.runs_over
|
181
|
+
sleep 1.1
|
182
|
+
end
|
183
|
+
|
184
|
+
def self.method_never_called; end
|
185
|
+
end
|
186
|
+
|
187
|
+
SlowModule.runs_out_of_time # Throws CustomError error in place of OutOfTime
|
188
|
+
SlowModule.runs_over_time # Throws CustomError error in place of DeadlineExceeded
|
189
|
+
```
|
190
|
+
|
191
|
+
## Development
|
192
|
+
|
193
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
194
|
+
|
195
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
196
|
+
|
197
|
+
## Contributing
|
198
|
+
|
199
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/execution_deadline. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
200
|
+
|
201
|
+
## License
|
202
|
+
|
203
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
204
|
+
|
205
|
+
## Code of Conduct
|
206
|
+
|
207
|
+
Everyone interacting in the ExecutionDeadline project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/execution_deadline/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "execution_deadline"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "execution_deadline/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "execution_deadline"
|
8
|
+
spec.version = ExecutionDeadline::VERSION
|
9
|
+
spec.authors = ["Brian Malinconico"]
|
10
|
+
|
11
|
+
spec.summary = %q{Manage code deadlines without the hard termination of Timeout}
|
12
|
+
spec.description = %q{Easily create and enforce deadline timings for code without the harsh termination of the Timeout module.}
|
13
|
+
spec.homepage = "https://github.com/arjes/execution_deadline"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Specify which files should be added to the gem when it is released.
|
17
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
18
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
19
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
end
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'execution_deadline/errors'
|
4
|
+
|
5
|
+
module ExecutionDeadline
|
6
|
+
class Deadline
|
7
|
+
def initialize(expires_at:, raises: nil)
|
8
|
+
@expires_at = expires_at
|
9
|
+
@raises = raises
|
10
|
+
end
|
11
|
+
|
12
|
+
def runs_for(duration)
|
13
|
+
time_left < duration &&
|
14
|
+
raise(
|
15
|
+
@raises || OutOfTime,
|
16
|
+
"Unable to run method expected run time #{duration} " \
|
17
|
+
"but only #{time_left}s left"
|
18
|
+
)
|
19
|
+
|
20
|
+
yield.tap do
|
21
|
+
expired? && raise(@raises || DeadlineExceeded)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def time_left
|
26
|
+
@expires_at - Time.now
|
27
|
+
end
|
28
|
+
|
29
|
+
def expired?
|
30
|
+
@expires_at <= Time.now
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'execution_deadline/version'
|
4
|
+
require 'execution_deadline/deadline'
|
5
|
+
|
6
|
+
module ExecutionDeadline
|
7
|
+
module Helpers
|
8
|
+
UNWRAPPED_METHOD_NAME_SUFFIX = "_without_deadline"
|
9
|
+
WRAPPED_METHOD = Proc.new do |options|
|
10
|
+
Proc.new do |*args, &blk|
|
11
|
+
set_deadline = options[:in] && ExecutionDeadline.set_deadline(
|
12
|
+
expires_at: Time.now + options[:in],
|
13
|
+
raises: options[:raises]
|
14
|
+
)
|
15
|
+
|
16
|
+
if ExecutionDeadline.current_deadline && options[:runs_for]
|
17
|
+
ExecutionDeadline.current_deadline.runs_for(options[:runs_for]) do
|
18
|
+
send(options[:aliased_method_name], *args, &blk)
|
19
|
+
end
|
20
|
+
else
|
21
|
+
send(options[:aliased_method_name], *args, &blk)
|
22
|
+
end
|
23
|
+
ensure
|
24
|
+
ExecutionDeadline.clear_deadline! if set_deadline
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def deadline(options = {})
|
29
|
+
options[:in] ||
|
30
|
+
options[:runs_for] ||
|
31
|
+
raise('expected deadline to include either :in or :runs_for')
|
32
|
+
|
33
|
+
@last_deadline_config = options
|
34
|
+
end
|
35
|
+
|
36
|
+
def method_added(method_name)
|
37
|
+
return super unless _has_deadline_config?
|
38
|
+
|
39
|
+
options = _fetch_and_reset_deadline_config
|
40
|
+
options[:aliased_method_name] ||= "_#{method_name}#{UNWRAPPED_METHOD_NAME_SUFFIX}".to_sym
|
41
|
+
|
42
|
+
alias_method options[:aliased_method_name], method_name
|
43
|
+
|
44
|
+
define_method(method_name, &WRAPPED_METHOD.call(options))
|
45
|
+
end
|
46
|
+
|
47
|
+
def singleton_method_added(method_name)
|
48
|
+
return super unless _has_deadline_config?
|
49
|
+
|
50
|
+
options = _fetch_and_reset_deadline_config
|
51
|
+
|
52
|
+
options[:aliased_method_name] ||= "_#{method_name}#{UNWRAPPED_METHOD_NAME_SUFFIX}".to_sym
|
53
|
+
|
54
|
+
singleton_class.class_eval do
|
55
|
+
alias_method options[:aliased_method_name], method_name
|
56
|
+
end
|
57
|
+
|
58
|
+
define_singleton_method(method_name, &WRAPPED_METHOD.call(options))
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def _has_deadline_config?
|
64
|
+
!(@last_deadline_config.nil? || @last_deadline_config == {})
|
65
|
+
end
|
66
|
+
|
67
|
+
def _fetch_and_reset_deadline_config
|
68
|
+
@last_deadline_config.tap { @last_deadline_config = nil }
|
69
|
+
end
|
70
|
+
|
71
|
+
def _add_deadlined_method(method_name, options)
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'execution_deadline/version'
|
4
|
+
require 'execution_deadline/helpers'
|
5
|
+
|
6
|
+
module ExecutionDeadline
|
7
|
+
def self.current_deadline
|
8
|
+
Thread.current[:deadline]
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.clear_deadline!
|
12
|
+
Thread.current[:deadline] = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
# @param expires_at [Time] The time at which to set the current deadline to
|
16
|
+
# expire
|
17
|
+
# @return [Boolean|Deadline] returns false if a deadline is already set, and
|
18
|
+
# returns a deadline object if it was successfully set
|
19
|
+
def self.set_deadline(expires_at:, raises: nil)
|
20
|
+
!current_deadline &&
|
21
|
+
Thread.current[:deadline] = Deadline.new(expires_at: expires_at, raises: raises)
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: execution_deadline
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Malinconico
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-09-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
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: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Easily create and enforce deadline timings for code without the harsh
|
56
|
+
termination of the Timeout module.
|
57
|
+
email:
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
|
+
- CODE_OF_CONDUCT.md
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/console
|
71
|
+
- bin/setup
|
72
|
+
- execution_deadline.gemspec
|
73
|
+
- lib/execution_deadline.rb
|
74
|
+
- lib/execution_deadline/deadline.rb
|
75
|
+
- lib/execution_deadline/errors.rb
|
76
|
+
- lib/execution_deadline/helpers.rb
|
77
|
+
- lib/execution_deadline/version.rb
|
78
|
+
homepage: https://github.com/arjes/execution_deadline
|
79
|
+
licenses:
|
80
|
+
- MIT
|
81
|
+
metadata: {}
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 2.7.6
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
101
|
+
summary: Manage code deadlines without the hard termination of Timeout
|
102
|
+
test_files: []
|