proletariat 0.0.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -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