cutoff 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/lib/cutoff/patch/net_http.rb +25 -16
- data/lib/cutoff/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ac27ce016591276e55afa82f64c08de370a969cb6552cc0d5ae69093d3a9e0c
|
4
|
+
data.tar.gz: 31e989979ae04de967a22e8d2457d6da654862603f380dd7521e415c9220148b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4241c63fc4c647c44860aa0781e2966a5eadc1d7edea259851018308d1877d664c46a8d90bd5553f725d2e1fa5f767995b0f27327482bf2ce5128701908aa684
|
7
|
+
data.tar.gz: 64d599559055f6d8b3c384b88b5268b02317784bd44fd6be2384fd3c56b1f9da5a9cfb435c4af05c083ba20af6d8865f0c73a8fc46afff261ad70d43fc9c35e4
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [0.4.1] - 2021-10-02
|
11
|
+
|
12
|
+
- Fix Net::HTTP patch to override timeouts given to start
|
13
|
+
|
10
14
|
## [0.4.0] - 2021-10-01
|
11
15
|
|
12
16
|
- Add benchmarks and slight performance improvements
|
@@ -29,7 +33,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
29
33
|
- Cutoff class
|
30
34
|
- Mysql2 patch
|
31
35
|
|
32
|
-
[Unreleased]: https://github.com/justinhoward/cutoff/compare/v0.4.
|
36
|
+
[Unreleased]: https://github.com/justinhoward/cutoff/compare/v0.4.1...HEAD
|
37
|
+
[0.4.0]: https://github.com/justinhoward/cutoff/compare/v0.4.0...v0.4.1
|
33
38
|
[0.4.0]: https://github.com/justinhoward/cutoff/compare/v0.3.0...v0.4.0
|
34
39
|
[0.3.0]: https://github.com/justinhoward/cutoff/compare/v0.2.0...v0.3.0
|
35
40
|
[0.2.0]: https://github.com/justinhoward/cutoff/compare/v0.1.0...v0.2.0
|
@@ -4,27 +4,36 @@ require 'net/http'
|
|
4
4
|
|
5
5
|
class Cutoff
|
6
6
|
module Patch
|
7
|
-
# Adds a checkpoint for starting HTTP requests and sets network timeouts
|
8
|
-
# to the remaining time
|
9
7
|
module NetHttp
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
def self.gen_timeout_method(name)
|
9
|
+
<<~RUBY
|
10
|
+
if #{name}.nil? || #{name} > remaining
|
11
|
+
self.#{name} = cutoff.seconds_remaining
|
12
|
+
end
|
13
|
+
RUBY
|
14
|
+
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
@write_timeout = cutoff.seconds_remaining
|
16
|
+
def self.use_write_timeout?
|
17
|
+
Gem::Version.new(RUBY_VERSION) > Gem::Version.new('2.6')
|
19
18
|
end
|
20
19
|
|
21
|
-
# Same as the original start, but
|
20
|
+
# Same as the original start, but adds a checkpoint for starting HTTP
|
21
|
+
# requests and sets network timeouts to the remaining time
|
22
22
|
#
|
23
|
-
# @see
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
# @see Net::HTTP#start
|
24
|
+
module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
|
25
|
+
def start
|
26
|
+
if (cutoff = Cutoff.current)
|
27
|
+
remaining = cutoff.seconds_remaining
|
28
|
+
#{gen_timeout_method('open_timeout')}
|
29
|
+
#{gen_timeout_method('read_timeout')}
|
30
|
+
#{gen_timeout_method('write_timeout') if use_write_timeout?}
|
31
|
+
#{gen_timeout_method('continue_timeout')}
|
32
|
+
Cutoff.checkpoint!
|
33
|
+
end
|
34
|
+
super
|
35
|
+
end
|
36
|
+
RUBY
|
28
37
|
end
|
29
38
|
end
|
30
39
|
end
|
data/lib/cutoff/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cutoff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Howard
|
@@ -111,7 +111,7 @@ licenses:
|
|
111
111
|
- MIT
|
112
112
|
metadata:
|
113
113
|
changelog_uri: https://github.com/justinhoward/cutoff/blob/master/CHANGELOG.md
|
114
|
-
documentation_uri: https://www.rubydoc.info/gems/cutoff/0.4.
|
114
|
+
documentation_uri: https://www.rubydoc.info/gems/cutoff/0.4.1
|
115
115
|
post_install_message:
|
116
116
|
rdoc_options: []
|
117
117
|
require_paths:
|