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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20820f3c865f6723365bbd709449442c7c28a9fc
4
- data.tar.gz: 5cf7d98a219fa334f607968733807fb622e028ad
3
+ metadata.gz: d6ccd098769b0b630161eb92038c13e662a58786
4
+ data.tar.gz: 0a99540886529b095b99a745514b54cf49a75cf2
5
5
  SHA512:
6
- metadata.gz: e8cee2c73f6ee889aa88585a445ac8d6515de5ca53eddbf17acfce3a00bb944702d6efc7d0342d4ddc38b04fc54c35a65d3c3277e14c640a569693d4262de176
7
- data.tar.gz: 908e324fde84ae503789e00755f8c912812adc76406c72c1fd18991972dc677bf33032da68b9cdc2c8fe2d89c85a90c11401be7b60d2b8dfdaae39465b1e1297
6
+ metadata.gz: b9d74d6377d9abc828a43333460966ab7779499c75ece7fe78c68f9b1002572322da70754ed7032ccc963ceac797aa2cb7df0ac77a19b80e8ad13f559bb5001f
7
+ data.tar.gz: 83a79b2a2ecdb619f781d8dcb2b2e50d6cea08d3a34e134b1c13f29fa129b7e4e92eb671bf4fe43b37788386690bf9273fa85f3ccb3a795536238e17d3a289e7
data/.travis.yml CHANGED
@@ -4,6 +4,7 @@ rvm:
4
4
  - jruby-19mode
5
5
  - rbx-2
6
6
  - 2.0.0
7
+ - 2.1.0
7
8
  - ruby-head
8
9
  matrix:
9
10
  allow_failures:
data/CHANGES.md CHANGED
@@ -1,3 +1,10 @@
1
+ 1.6.0
2
+ --------
3
+
4
+ - Update to use Celluloid `0.17.2`
5
+ - Removed the `SuckerPunch.clear_queues` method
6
+
7
+
1
8
  1.5.1
2
9
  --------
3
10
 
data/README.md CHANGED
@@ -166,7 +166,7 @@ Full job data can be reported like this:
166
166
  ```Ruby
167
167
  def perform(all, my, arguments)
168
168
  ... your code ...
169
- rescue Exception
169
+ rescue StandardError
170
170
  Airbrake.error($!, [self.class.name, all, my, arguments].inspect)
171
171
  raise
172
172
  end
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)
@@ -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
- self.pool = klass.send(:pool, { size: num_workers })
62
- end
63
-
64
- def register_celluloid_pool
65
- Celluloid::Actor[name] = pool
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
@@ -3,9 +3,5 @@ module SuckerPunch
3
3
  initializer "sucker_punch.logger" do
4
4
  SuckerPunch.logger = Rails.logger
5
5
  end
6
-
7
- config.to_prepare do
8
- SuckerPunch.clear_queues
9
- end
10
6
  end
11
7
  end
@@ -1,13 +1,11 @@
1
1
  require 'sucker_punch'
2
- require "celluloid/proxies/abstract_proxy"
3
- require "celluloid/proxies/sync_proxy"
4
- require "celluloid/proxies/actor_proxy"
2
+ require 'celluloid/proxy/abstract'
3
+ require 'celluloid/proxy/sync'
4
+ require 'celluloid/proxy/actor'
5
5
 
6
- module Celluloid
7
- class CellProxy < SyncProxy
8
- def async(method_name = nil, *args, &block)
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
 
@@ -1,3 +1,3 @@
1
1
  module SuckerPunch
2
- VERSION = "1.5.1"
2
+ VERSION = "1.6.0"
3
3
  end
@@ -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 == Celluloid::PoolManager
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 a celluloid pool" do
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
@@ -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
@@ -22,5 +22,5 @@ Gem::Specification.new do |gem|
22
22
  gem.add_development_dependency "rake"
23
23
  gem.add_development_dependency "pry"
24
24
 
25
- gem.add_dependency "celluloid", "0.16.0"
25
+ gem.add_dependency "celluloid", "~> 0.17.2"
26
26
  end
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.5.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-08-20 00:00:00.000000000 Z
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.16.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.16.0
68
+ version: 0.17.2
69
69
  description: Asynchronous processing library for Ruby
70
70
  email:
71
71
  - brandonhilkert@gmail.com