proletariat 0.0.6 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/README.md +2 -1
- data/lib/proletariat.rb +15 -2
- data/lib/proletariat/concurrency/actor.rb +12 -67
- data/lib/proletariat/concurrency/actor_common.rb +30 -0
- data/lib/proletariat/concurrency/poolable_actor.rb +25 -0
- data/lib/proletariat/configuration.rb +15 -0
- data/lib/proletariat/cucumber.rb +2 -4
- data/lib/proletariat/exception_handler.rb +45 -0
- data/lib/proletariat/exception_handler/drop.rb +15 -0
- data/lib/proletariat/exception_handler/exponential_backoff.rb +130 -0
- data/lib/proletariat/manager.rb +30 -28
- data/lib/proletariat/message.rb +9 -0
- data/lib/proletariat/publisher.rb +19 -41
- data/lib/proletariat/runner.rb +18 -30
- data/lib/proletariat/subscriber.rb +91 -177
- data/lib/proletariat/tasks.rb +1 -1
- data/lib/proletariat/testing/expectation_guarantor.rb +36 -30
- data/lib/proletariat/version.rb +1 -1
- data/lib/proletariat/worker.rb +47 -34
- data/proletariat.gemspec +3 -3
- data/spec/lib/proletariat_spec.rb +18 -7
- data/spec/lib/testing/expectation_guarantor_spec.rb +0 -32
- data/spec/lib/worker_spec.rb +13 -15
- metadata +15 -12
- data/lib/proletariat/concurrency/supervisor.rb +0 -31
- data/spec/lib/publisher_spec.rb +0 -36
@@ -1,31 +0,0 @@
|
|
1
|
-
module Proletariat
|
2
|
-
class Supervisor
|
3
|
-
extend Forwardable
|
4
|
-
|
5
|
-
def_delegators :true_supervisor, :run, :run!, :stop, :running?, :add_worker
|
6
|
-
|
7
|
-
def [](mailbox_name)
|
8
|
-
mailboxes[mailbox_name]
|
9
|
-
end
|
10
|
-
|
11
|
-
def add_supervisor(supervisor, opts = {})
|
12
|
-
true_supervisor.add_worker supervisor, opts.merge(type: :supervisor)
|
13
|
-
end
|
14
|
-
|
15
|
-
def supervise_pool(mailbox_name, threads, actor_class, *arguments)
|
16
|
-
mailboxes[mailbox_name], workers = Actor.pool(threads, actor_class,
|
17
|
-
*arguments)
|
18
|
-
true_supervisor.add_workers workers
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def mailboxes
|
24
|
-
@mailboxes ||= {}
|
25
|
-
end
|
26
|
-
|
27
|
-
def true_supervisor
|
28
|
-
@true_supervisor ||= Concurrent::Supervisor.new
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/spec/lib/publisher_spec.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'proletariat/publisher'
|
2
|
-
|
3
|
-
module Proletariat
|
4
|
-
describe Publisher do
|
5
|
-
let(:connection) { double.as_null_object }
|
6
|
-
let(:exchange_name) { 'great-exchange' }
|
7
|
-
let(:logger) { double }
|
8
|
-
|
9
|
-
before do
|
10
|
-
allow(Proletariat).to receive(:connection).and_return(connection)
|
11
|
-
allow(Proletariat).to receive(:exchange_name).and_return(exchange_name)
|
12
|
-
allow(Proletariat).to receive(:logger).and_return(logger)
|
13
|
-
end
|
14
|
-
|
15
|
-
describe '#started' do
|
16
|
-
it 'should log status' do
|
17
|
-
expect(logger).to receive(:info).with /online/
|
18
|
-
Publisher.new.started
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '#stopped' do
|
23
|
-
it 'should log status' do
|
24
|
-
expect(logger).to receive(:info).with /offline/
|
25
|
-
Publisher.new.stopped
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe '#stopping' do
|
30
|
-
it 'should log status' do
|
31
|
-
expect(logger).to receive(:info).with /graceful shutdown/
|
32
|
-
Publisher.new.stopping
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|