sucker_punch 1.5.1 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGES.md +7 -0
- data/README.md +1 -1
- data/lib/sucker_punch.rb +1 -5
- data/lib/sucker_punch/queue.rb +6 -19
- data/lib/sucker_punch/railtie.rb +0 -4
- data/lib/sucker_punch/testing/inline.rb +6 -8
- data/lib/sucker_punch/version.rb +1 -1
- data/spec/sucker_punch/queue_spec.rb +2 -33
- data/spec/sucker_punch_spec.rb +0 -10
- data/sucker_punch.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6ccd098769b0b630161eb92038c13e662a58786
|
4
|
+
data.tar.gz: 0a99540886529b095b99a745514b54cf49a75cf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9d74d6377d9abc828a43333460966ab7779499c75ece7fe78c68f9b1002572322da70754ed7032ccc963ceac797aa2cb7df0ac77a19b80e8ad13f559bb5001f
|
7
|
+
data.tar.gz: 83a79b2a2ecdb619f781d8dcb2b2e50d6cea08d3a34e134b1c13f29fa129b7e4e92eb671bf4fe43b37788386690bf9273fa85f3ccb3a795536238e17d3a289e7
|
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
data/README.md
CHANGED
data/lib/sucker_punch.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'celluloid'
|
1
|
+
require 'celluloid/current'
|
2
2
|
require 'sucker_punch/core_ext'
|
3
3
|
require 'sucker_punch/job'
|
4
4
|
require 'sucker_punch/queue'
|
@@ -16,10 +16,6 @@ module SuckerPunch
|
|
16
16
|
def self.exception_handler(&block)
|
17
17
|
Celluloid.exception_handler(&block)
|
18
18
|
end
|
19
|
-
|
20
|
-
def self.clear_queues
|
21
|
-
SuckerPunch::Queue.clear_all
|
22
|
-
end
|
23
19
|
end
|
24
20
|
|
25
21
|
require 'sucker_punch/railtie' if defined?(::Rails)
|
data/lib/sucker_punch/queue.rb
CHANGED
@@ -3,7 +3,6 @@ require 'thread'
|
|
3
3
|
module SuckerPunch
|
4
4
|
class Queue
|
5
5
|
attr_reader :klass
|
6
|
-
attr_accessor :pool
|
7
6
|
|
8
7
|
DEFAULT_OPTIONS = { workers: 2 }
|
9
8
|
PREFIX = "sucker_punch"
|
@@ -15,20 +14,8 @@ module SuckerPunch
|
|
15
14
|
Celluloid::Actor[queue.name]
|
16
15
|
end
|
17
16
|
|
18
|
-
def self.clear_all
|
19
|
-
Celluloid::Actor.all.each do |actor|
|
20
|
-
registered_name = actor.registered_name.to_s
|
21
|
-
matches = registered_name.match(PREFIX).to_a
|
22
|
-
|
23
|
-
if matches.any?
|
24
|
-
Celluloid::Actor.delete(registered_name)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
17
|
def initialize(klass)
|
30
18
|
@klass = klass
|
31
|
-
@pool = nil
|
32
19
|
@mutex = Mutex.new
|
33
20
|
end
|
34
21
|
|
@@ -40,7 +27,6 @@ module SuckerPunch
|
|
40
27
|
@mutex.synchronize {
|
41
28
|
unless registered?
|
42
29
|
initialize_celluloid_pool(num_workers)
|
43
|
-
register_celluloid_pool
|
44
30
|
end
|
45
31
|
}
|
46
32
|
self.class.find(klass)
|
@@ -58,11 +44,12 @@ module SuckerPunch
|
|
58
44
|
private
|
59
45
|
|
60
46
|
def initialize_celluloid_pool(num_workers)
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
47
|
+
pool_class = klass
|
48
|
+
pool_name = name
|
49
|
+
pool = Class.new(Celluloid::Supervision::Container) do
|
50
|
+
pool pool_class, as: pool_name, size: num_workers
|
51
|
+
end
|
52
|
+
pool.run!
|
66
53
|
end
|
67
54
|
end
|
68
55
|
end
|
data/lib/sucker_punch/railtie.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
require 'sucker_punch'
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
2
|
+
require 'celluloid/proxy/abstract'
|
3
|
+
require 'celluloid/proxy/sync'
|
4
|
+
require 'celluloid/proxy/actor'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
self
|
10
|
-
end
|
6
|
+
class Celluloid::Proxy::Cell < Celluloid::Proxy::Sync
|
7
|
+
def async(method_name = nil, *args, &block)
|
8
|
+
self
|
11
9
|
end
|
12
10
|
end
|
13
11
|
|
data/lib/sucker_punch/version.rb
CHANGED
@@ -19,33 +19,7 @@ describe SuckerPunch::Queue do
|
|
19
19
|
it "returns the Celluloid Actor from the registry" do
|
20
20
|
SuckerPunch::Queue.new(FakeJob).register
|
21
21
|
queue = SuckerPunch::Queue.find(FakeJob)
|
22
|
-
queue.class
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe ".clear_all" do
|
27
|
-
it "removes SuckerPunch actors from Celluloid registry" do
|
28
|
-
sucker_punch_actor_name = "#{SuckerPunch::Queue::PREFIX}_fake_job".to_sym
|
29
|
-
Celluloid::Actor[sucker_punch_actor_name] = FakeJob.new
|
30
|
-
|
31
|
-
SuckerPunch::Queue.clear_all
|
32
|
-
|
33
|
-
expect(Celluloid::Actor[sucker_punch_actor_name]).to be_nil
|
34
|
-
end
|
35
|
-
|
36
|
-
it "does not remove non-SuckerPunch actors from Celluloid registry" do
|
37
|
-
class ::OtherJob
|
38
|
-
include ::Celluloid
|
39
|
-
def self.pool(options); end
|
40
|
-
def perform; end
|
41
|
-
end
|
42
|
-
actor_name = :other_job
|
43
|
-
job = OtherJob.new
|
44
|
-
Celluloid::Actor[actor_name] = job
|
45
|
-
|
46
|
-
SuckerPunch::Queue.clear_all
|
47
|
-
|
48
|
-
expect(Celluloid::Actor[actor_name]).to eq job
|
22
|
+
expect(queue.class).to eq Celluloid::Supervision::Container::Pool
|
49
23
|
end
|
50
24
|
end
|
51
25
|
|
@@ -53,12 +27,7 @@ describe SuckerPunch::Queue do
|
|
53
27
|
let(:job) { FakeJob }
|
54
28
|
let(:queue) { SuckerPunch::Queue.new(job) }
|
55
29
|
|
56
|
-
it "initializes
|
57
|
-
queue.register
|
58
|
-
expect(queue.pool.class).to eq(Celluloid::PoolManager)
|
59
|
-
end
|
60
|
-
|
61
|
-
it "registers the pool with Celluloid" do
|
30
|
+
it "initializes and registers the pool with Celluloid" do
|
62
31
|
expected_pool_name = "#{SuckerPunch::Queue::PREFIX}_fake_job".to_sym
|
63
32
|
|
64
33
|
pool = queue.register
|
data/spec/sucker_punch_spec.rb
CHANGED
@@ -11,14 +11,4 @@ describe SuckerPunch do
|
|
11
11
|
SuckerPunch.logger = nil
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
15
|
-
describe '.clear_queues' do
|
16
|
-
it "clears SuckerPunch queues" do
|
17
|
-
allow(SuckerPunch::Queue).to receive(:clear_all)
|
18
|
-
|
19
|
-
SuckerPunch.clear_queues
|
20
|
-
|
21
|
-
expect(SuckerPunch::Queue).to have_received(:clear_all)
|
22
|
-
end
|
23
|
-
end
|
24
14
|
end
|
data/sucker_punch.gemspec
CHANGED
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: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Hilkert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: celluloid
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.17.2
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 0.17.2
|
69
69
|
description: Asynchronous processing library for Ruby
|
70
70
|
email:
|
71
71
|
- brandonhilkert@gmail.com
|