sucker_punch 2.1.2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/lib/sucker_punch/async_syntax.rb +2 -3
- data/lib/sucker_punch/job.rb +13 -7
- data/lib/sucker_punch/queue.rb +3 -4
- data/lib/sucker_punch/testing.rb +1 -1
- data/lib/sucker_punch/testing/inline.rb +5 -5
- data/lib/sucker_punch/version.rb +1 -1
- data/test/sucker_punch/job_test.rb +0 -1
- data/test/sucker_punch/queue_test.rb +2 -2
- data/test/sucker_punch_test.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1edad787473a077f23f2fae95150cdb92e3834a12150fbd4d910fade5692516
|
4
|
+
data.tar.gz: 4ba7b7fa6cf3a1c99706a3bda43b0fd2fc291ae1825a23466b00a5b7a3354003
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8184cafe29937ad818920951c3c760e8435b4e35a348e27629053bae1b56e2f44ab412154fb3769e6878034a9351ad5e60fb44d9385bf5bb4f2bf58cc91c71c
|
7
|
+
data.tar.gz: fde16057612312085f59a955e783007b6a0cf0b4ff7d08312963bc0c76b3be2e5d254e5eb1df1625db3c554403485e5df8a1c995ab50b71dda4e1358b00e8d23
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
3.0.0
|
2
|
+
-------
|
3
|
+
- Add support for keyword arguments in ruby `>= 3.0`. More details in [release notes](https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/).
|
4
|
+
|
1
5
|
2.1.1
|
2
6
|
-------
|
3
7
|
- Relax versioning constraint of `concurrent-ruby` to make way for 1.1 release
|
data/lib/sucker_punch/job.rb
CHANGED
@@ -32,17 +32,17 @@ module SuckerPunch
|
|
32
32
|
end
|
33
33
|
|
34
34
|
module ClassMethods
|
35
|
-
def perform_async(*args)
|
35
|
+
def perform_async(*args, **kwargs)
|
36
36
|
return unless SuckerPunch::RUNNING.true?
|
37
37
|
queue = SuckerPunch::Queue.find_or_create(self.to_s, num_workers, num_jobs_max)
|
38
|
-
queue.post
|
38
|
+
queue.post { __run_perform(*args, **kwargs) }
|
39
39
|
end
|
40
40
|
|
41
|
-
def perform_in(interval, *args)
|
41
|
+
def perform_in(interval, *args, **kwargs)
|
42
42
|
return unless SuckerPunch::RUNNING.true?
|
43
43
|
queue = SuckerPunch::Queue.find_or_create(self.to_s, num_workers, num_jobs_max)
|
44
44
|
job = Concurrent::ScheduledTask.execute(interval.to_f, args: args, executor: queue) do
|
45
|
-
__run_perform(*args)
|
45
|
+
__run_perform(*args, **kwargs)
|
46
46
|
end
|
47
47
|
job.pending?
|
48
48
|
end
|
@@ -55,14 +55,20 @@ module SuckerPunch
|
|
55
55
|
self.num_jobs_max = num
|
56
56
|
end
|
57
57
|
|
58
|
-
def __run_perform(*args)
|
58
|
+
def __run_perform(*args, **kwargs)
|
59
59
|
SuckerPunch::Counter::Busy.new(self.to_s).increment
|
60
|
-
|
60
|
+
|
61
|
+
result = if RUBY_VERSION >= '2.5'
|
62
|
+
self.new.perform(*args, **kwargs)
|
63
|
+
else
|
64
|
+
self.new.perform(*args, *(kwargs.any? ? [kwargs] : nil))
|
65
|
+
end
|
66
|
+
|
61
67
|
SuckerPunch::Counter::Processed.new(self.to_s).increment
|
62
68
|
result
|
63
69
|
rescue => ex
|
64
70
|
SuckerPunch::Counter::Failed.new(self.to_s).increment
|
65
|
-
SuckerPunch.exception_handler.call(ex, self, args)
|
71
|
+
SuckerPunch.exception_handler.call(ex, self, [*args, **kwargs])
|
66
72
|
ensure
|
67
73
|
SuckerPunch::Counter::Busy.new(self.to_s).decrement
|
68
74
|
end
|
data/lib/sucker_punch/queue.rb
CHANGED
@@ -24,7 +24,7 @@ module SuckerPunch
|
|
24
24
|
max_threads: num_workers,
|
25
25
|
max_queue: num_jobs_max || DEFAULT_MAX_QUEUE_SIZE
|
26
26
|
)
|
27
|
-
Concurrent::ThreadPoolExecutor.new(options)
|
27
|
+
Concurrent::ThreadPoolExecutor.new(**options)
|
28
28
|
end
|
29
29
|
|
30
30
|
new(name, pool)
|
@@ -165,10 +165,10 @@ module SuckerPunch
|
|
165
165
|
SuckerPunch::Counter::Failed.new(name).value
|
166
166
|
end
|
167
167
|
|
168
|
-
def post(*args, &block)
|
168
|
+
def post(*args, **kwargs, &block)
|
169
169
|
synchronize do
|
170
170
|
if @running
|
171
|
-
@pool.post(*args, &block)
|
171
|
+
@pool.post(*args, **kwargs, &block)
|
172
172
|
else
|
173
173
|
false
|
174
174
|
end
|
@@ -191,4 +191,3 @@ module SuckerPunch
|
|
191
191
|
end
|
192
192
|
end
|
193
193
|
end
|
194
|
-
|
data/lib/sucker_punch/testing.rb
CHANGED
@@ -17,7 +17,7 @@ require 'sucker_punch'
|
|
17
17
|
#
|
18
18
|
# Include inline testing lib:
|
19
19
|
#
|
20
|
-
# require 'sucker_punch/testing/inline
|
20
|
+
# require 'sucker_punch/testing/inline'
|
21
21
|
#
|
22
22
|
# LogJob.perform_async(1, 2, 3) is now synchronous
|
23
23
|
# LogJob.perform_in(1, 2, 3) is now synchronous
|
@@ -25,12 +25,12 @@ require 'sucker_punch'
|
|
25
25
|
module SuckerPunch
|
26
26
|
module Job
|
27
27
|
module ClassMethods
|
28
|
-
def perform_async(*args)
|
29
|
-
self.new.perform(*args)
|
28
|
+
def perform_async(*args, **kwargs)
|
29
|
+
self.new.perform(*args, **kwargs)
|
30
30
|
end
|
31
31
|
|
32
|
-
def perform_in(_, *args)
|
33
|
-
self.new.perform(*args)
|
32
|
+
def perform_in(_, *args, **kwargs)
|
33
|
+
self.new.perform(*args, **kwargs)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
data/lib/sucker_punch/version.rb
CHANGED
data/test/sucker_punch_test.rb
CHANGED
@@ -41,7 +41,7 @@ class SuckerPunchTest < Minitest::Test
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_exception_handler_can_be_set
|
44
|
-
SuckerPunch.exception_handler = -> (
|
44
|
+
SuckerPunch.exception_handler = -> (_ex, _, _) { raise "bad stuff" }
|
45
45
|
assert_raises(::RuntimeError) { SuckerPunch.exception_handler.call(StandardError.new("bad"), nil, nil) }
|
46
46
|
end
|
47
47
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sucker_punch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Hilkert
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -123,8 +123,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
|
-
rubygems_version: 3.
|
127
|
-
signing_key:
|
126
|
+
rubygems_version: 3.1.2
|
127
|
+
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: Sucker Punch is a Ruby asynchronous processing using concurrent-ruby, heavily
|
130
130
|
influenced by Sidekiq and girl_friday.
|