cutoff 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/CHANGELOG.md +14 -1
- data/README.md +1 -1
- data/lib/cutoff/patch/mysql2.rb +6 -1
- data/lib/cutoff/patch/net_http.rb +20 -10
- data/lib/cutoff/rails/controller.rb +7 -1
- data/lib/cutoff/sidekiq.rb +5 -4
- data/lib/cutoff/timer.rb +1 -0
- data/lib/cutoff/version.rb +1 -1
- metadata +4 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ab1dba25fcad8b3f65d816d1740dbd2c2e1b6102f4009e19fa36fd0baf8236c
|
4
|
+
data.tar.gz: 7a86b6dbf5c0d0bd6631281687c674ec21dc19102097bee351b8e13a3b2a53c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e23dcd3d2fa5b44bcc3630aa4976cff12eef9771f4c1010a2cd12cc820ef5caabf1e54b0dba83de60af1ce2142eea4d53bae7c79e5c02ac34ec91d1e07cfba62
|
7
|
+
data.tar.gz: bfc01027499784eaeaf89f5bc4114483bf89bc41eb2db6668a297ace172b58136ae58b214df6f0929a027729aff417ff56b9fb4dfacd45cb979d280b675f3868
|
data/.yardopts
CHANGED
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [0.5.1] - 2022-09-06
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
|
14
|
+
- Upgrade rubocop to latest version #12 justinhoward
|
15
|
+
- Add codecov.io code coverage #11 justinhoward
|
16
|
+
- Complete yard documentation and fix warnings #13 justinhoward
|
17
|
+
|
18
|
+
### Fixed
|
19
|
+
|
20
|
+
- Pull cutoff option from job, not worker #14 mperham
|
21
|
+
|
10
22
|
## [0.5.0] - 2022-08-10
|
11
23
|
|
12
24
|
### Changed
|
@@ -58,7 +70,8 @@ to `Timeout::Error`. `CutoffError` changes from a class to a module.
|
|
58
70
|
- Cutoff class
|
59
71
|
- Mysql2 patch
|
60
72
|
|
61
|
-
[Unreleased]: https://github.com/justinhoward/cutoff/compare/v0.5.
|
73
|
+
[Unreleased]: https://github.com/justinhoward/cutoff/compare/v0.5.1...HEAD
|
74
|
+
[0.5.1]: https://github.com/justinhoward/cutoff/compare/v0.5.0...v0.5.1
|
62
75
|
[0.5.0]: https://github.com/justinhoward/cutoff/compare/v0.4.2...v0.5.0
|
63
76
|
[0.4.2]: https://github.com/justinhoward/cutoff/compare/v0.4.1...v0.4.2
|
64
77
|
[0.4.1]: https://github.com/justinhoward/cutoff/compare/v0.4.0...v0.4.1
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ Cutoff
|
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/cutoff.svg)](https://badge.fury.io/rb/cutoff)
|
5
5
|
[![CI](https://github.com/justinhoward/cutoff/workflows/CI/badge.svg)](https://github.com/justinhoward/cutoff/actions?query=workflow%3ACI+branch%3Amaster)
|
6
6
|
[![Code Quality](https://app.codacy.com/project/badge/Grade/2748da79ec294f909996a56f11caac4a)](https://www.codacy.com/gh/justinhoward/cutoff/dashboard?utm_source=github.com&utm_medium=referral&utm_content=justinhoward/cutoff&utm_campaign=Badge_Grade)
|
7
|
-
[![Code Coverage](https://
|
7
|
+
[![Code Coverage](https://codecov.io/gh/justinhoward/cutoff/branch/master/graph/badge.svg?token=COVM3D2PTG)](https://codecov.io/gh/justinhoward/cutoff)
|
8
8
|
[![Inline docs](http://inch-ci.org/github/justinhoward/cutoff.svg?branch=master)](http://inch-ci.org/github/justinhoward/cutoff)
|
9
9
|
|
10
10
|
A deadlines library for Ruby inspired by Shopify and
|
data/lib/cutoff/patch/mysql2.rb
CHANGED
@@ -8,21 +8,26 @@ class Cutoff
|
|
8
8
|
# to the remaining cutoff time. You can select this patch with
|
9
9
|
# `exclude` or `only` using the checkpoint name `:net_http`.
|
10
10
|
module NetHttp
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
class << self
|
12
|
+
private
|
13
|
+
|
14
|
+
def gen_timeout_method(name)
|
15
|
+
<<~RUBY
|
16
|
+
if #{name}.nil? || #{name} > remaining
|
17
|
+
self.#{name} = cutoff.seconds_remaining
|
18
|
+
end
|
19
|
+
RUBY
|
20
|
+
end
|
18
21
|
|
19
|
-
|
20
|
-
|
22
|
+
def use_write_timeout?
|
23
|
+
Gem::Version.new(RUBY_VERSION) > Gem::Version.new('2.6')
|
24
|
+
end
|
21
25
|
end
|
22
26
|
|
23
27
|
# Same as the original start, but adds a checkpoint for starting HTTP
|
24
28
|
# requests and sets network timeouts to the remaining time
|
25
29
|
#
|
30
|
+
# @method start
|
26
31
|
# @see Net::HTTP#start
|
27
32
|
module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
|
28
33
|
def start
|
@@ -41,4 +46,9 @@ class Cutoff
|
|
41
46
|
end
|
42
47
|
end
|
43
48
|
|
44
|
-
|
49
|
+
# @api external
|
50
|
+
module Net
|
51
|
+
class HTTP
|
52
|
+
prepend Cutoff::Patch::NetHttp
|
53
|
+
end
|
54
|
+
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'action_controller'
|
4
4
|
|
5
5
|
class Cutoff
|
6
|
+
# Cutoff Rails extensions
|
6
7
|
module Rails
|
7
8
|
# Rails controller integration
|
8
9
|
module Controller
|
@@ -45,4 +46,9 @@ class Cutoff
|
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
48
|
-
|
49
|
+
# @api external
|
50
|
+
module ActionController
|
51
|
+
class Base
|
52
|
+
extend Cutoff::Rails::Controller
|
53
|
+
end
|
54
|
+
end
|
data/lib/cutoff/sidekiq.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'sidekiq'
|
4
4
|
|
5
5
|
class Cutoff
|
6
|
+
# Cutoff sidekiq extensions
|
6
7
|
module Sidekiq
|
7
8
|
# Add an option `cutoff` for sidekiq workers
|
8
9
|
#
|
@@ -17,14 +18,14 @@ class Cutoff
|
|
17
18
|
# end
|
18
19
|
# end
|
19
20
|
class ServerMiddleware
|
20
|
-
# @param
|
21
|
-
# @param
|
21
|
+
# @param _worker [Object] the worker instance
|
22
|
+
# @param job [Hash] the full job payload
|
22
23
|
# @param _queue [String] queue the name of the queue the job was pulled
|
23
24
|
# from
|
24
25
|
# @yield the next middleware in the chain or worker `perform` method
|
25
26
|
# @return [void]
|
26
|
-
def call(
|
27
|
-
allowed_seconds =
|
27
|
+
def call(_worker, job, _queue)
|
28
|
+
allowed_seconds = job['cutoff']
|
28
29
|
return yield if allowed_seconds.nil?
|
29
30
|
|
30
31
|
Cutoff.wrap(allowed_seconds) { yield }
|
data/lib/cutoff/timer.rb
CHANGED
data/lib/cutoff/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cutoff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Howard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -38,34 +38,6 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '5.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rubocop
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 0.81.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.81.0
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rubocop-rspec
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - '='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 1.38.1
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - '='
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 1.38.1
|
69
41
|
- !ruby/object:Gem::Dependency
|
70
42
|
name: timecop
|
71
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,7 +84,8 @@ licenses:
|
|
112
84
|
- MIT
|
113
85
|
metadata:
|
114
86
|
changelog_uri: https://github.com/justinhoward/cutoff/blob/master/CHANGELOG.md
|
115
|
-
documentation_uri: https://www.rubydoc.info/gems/cutoff/0.5.
|
87
|
+
documentation_uri: https://www.rubydoc.info/gems/cutoff/0.5.1
|
88
|
+
rubygems_mfa_required: 'true'
|
116
89
|
post_install_message:
|
117
90
|
rdoc_options: []
|
118
91
|
require_paths:
|