ruby_rabbitmq_janus 3.0.0.pre.351 → 3.0.0.pre.352

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26081e2dcef6062935a89a824e2545e00303be4ea41272496692a5be73745a4b
4
- data.tar.gz: d84fc9d5f8f597cb4d8306f2e81c596df72687cbdb42ff05e80a1036d9d54363
3
+ metadata.gz: 9410fdf3db086fdaf0c7abd7c822612977718f0d2059869ec0bfd5522e30dacf
4
+ data.tar.gz: dfe4addba32bc68b336cb4db8177a791589cde45ed73d78799fc7d298ef129a0
5
5
  SHA512:
6
- metadata.gz: 51f97d6b078e8b371138dc14cef095c120a9de8cea32c7d665adc539aa83525e4dfcb833b7834a088d75dff80e819c7e480ad1434750cc0ec06e437ed5aae49e
7
- data.tar.gz: 233929c96f3f83c4ed996868a4c2b826234970ba75271441bac569c36a7cc2c396a79ad3586d368cb3b8eefb4df7bd680129024c32cc037a23b529f851d3dcf0
6
+ metadata.gz: 99ea49a811322ecc33e84b2f7fc03bc181b9b515520debbceaf922b59fc0007073ae571f4fb1e9004052c04596606efabacbfdda8a7157bbf411d8ca8f1b7900
7
+ data.tar.gz: 2ca3d7bc242cb865bc397f21d43be8504af0b2e40cb9c77907f4120867a2b10adc8fa9ada6d3b5714b9f4c33d41d871d1bc12cb9a92010731a9dbd47909b0c2b
@@ -36,6 +36,7 @@ end
36
36
 
37
37
  require 'rrj/errors/base/base'
38
38
  require 'rrj/errors/janus/janus'
39
- require 'rrj/errors/process/concurency'
39
+ require 'rrj/errors/process/event'
40
+ require 'rrj/errors/process/event_admin'
40
41
  require 'rrj/errors/tools/tools'
41
42
  require 'rrj/errors/rabbit/rabbit'
@@ -4,17 +4,15 @@ module RubyRabbitmqJanus
4
4
  module Errors
5
5
  module Process
6
6
  module Event
7
- # Error for Process::Concurrencies::Event#initialize
8
- class Initializer < RubyRabbitmqJanus::Errors::Process::BaseEvent
9
- def initializer
10
- super 'Event', 'Error Event initializer'
7
+ class Base < RubyRabbitmqJanus::Errors::RRJError
8
+ def initialize(klass, message, level = :warn)
9
+ super "[Concurrency][#{klass}] #{message}", level
11
10
  end
12
11
  end
13
12
 
14
- # Error for Process::Concurrencies::Event#run
15
- class Run < RubyRabbitmqJanus::Errors::Process::BaseEvent
16
- def initializer
17
- super 'Event', 'Error Event runner block code'
13
+ class Run < Base
14
+ def initialize
15
+ super 'Event', 'Failed start thread listener public queue !'
18
16
  end
19
17
  end
20
18
  end
@@ -4,17 +4,15 @@ module RubyRabbitmqJanus
4
4
  module Errors
5
5
  module Process
6
6
  module EventAdmin
7
- # Error for Process::Concurrencies::EventAdmin#initialize
8
- class Initializer < RubyRabbitmqJanus::Errors::Process::BaseEvent
9
- def initializer
10
- super 'EventAdmin', 'Error EventAdmin initializer'
7
+ class Base < RubyRabbitmqJanus::Errors::RRJError
8
+ def initialize(klass, message, level = :warn)
9
+ super "[Concurrency][#{klass}] #{message}", level
11
10
  end
12
11
  end
13
12
 
14
- # Error for Process::Concurrencies::EventAdmin#run
15
- class Run < RubyRabbitmqJanus::Errors::Process::BaseEvent
16
- def initializer
17
- super 'EventAdmin', 'Error EventAdmin runner block code'
13
+ class Run < Base
14
+ def initialize
15
+ super 'EventAdmin', 'Failed start thread listener public queue !'
18
16
  end
19
17
  end
20
18
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # rubocop:disable Metrics/LineLength
3
+ # rubocop:disable Layout/LineLength
4
4
 
5
5
  module RubyRabbitmqJanus
6
6
  module Janus
@@ -156,4 +156,4 @@ module RubyRabbitmqJanus
156
156
  end
157
157
  end
158
158
  end
159
- # rubocop:enable Metrics/LineLength
159
+ # rubocop:enable Layout/LineLength
@@ -27,6 +27,9 @@ module RubyRabbitmqJanus
27
27
  #
28
28
  # @return [Thread] It's a thread who listen queue and execute action
29
29
  def run(&block)
30
+ raise RubyRabbitmqJanus::Errors::Process::Event::Run \
31
+ unless block_given?
32
+
30
33
  @thread.join
31
34
  Thread.new do
32
35
  loop do
@@ -37,8 +40,11 @@ module RubyRabbitmqJanus
37
40
 
38
41
  private
39
42
 
43
+ def publisher
44
+ Rabbit::Listener::From.new(rabbit)
45
+ end
46
+
40
47
  def transaction_running
41
- publisher = Rabbit::Listener::From.new(rabbit)
42
48
  @thread.thread_variable_set(NAME_VAR, publisher)
43
49
  end
44
50
  end
@@ -27,6 +27,9 @@ module RubyRabbitmqJanus
27
27
  #
28
28
  # @return [Thread] It's a thread who listen queue and execute action
29
29
  def run(&block)
30
+ raise RubyRabbitmqJanus::Errors::Process::EventAdmin::Run \
31
+ unless block_given?
32
+
30
33
  @thread.join
31
34
  Thread.new do
32
35
  loop do
@@ -37,8 +40,11 @@ module RubyRabbitmqJanus
37
40
 
38
41
  private
39
42
 
43
+ def publisher
44
+ Rabbit::Listener::FromAdmin.new(rabbit)
45
+ end
46
+
40
47
  def transaction_running
41
- publisher = Rabbit::Listener::FromAdmin.new(rabbit)
42
48
  @thread.thread_variable_set(NAME_VAR, publisher)
43
49
  end
44
50
  end
@@ -2,7 +2,8 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe RubyRabbitmqJanus::Process::Concurrencies::Concurrency, type: :thread, name: :concurrency do
5
+ describe RubyRabbitmqJanus::Process::Concurrencies::Concurrency, type: :thread,
6
+ name: :concurrency do
6
7
  let(:concurrency) { described_class.new }
7
8
 
8
9
  it { expect(concurrency.send(:rabbit)).to be_a(RubyRabbitmqJanus::Rabbit::Connect) }
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe RubyRabbitmqJanus::Process::Concurrencies::EventAdmin, type: :thread,
6
+ name: :event_admin do
7
+ let(:publish_name) { :publish_adm }
8
+ let(:listener) { RubyRabbitmqJanus::Rabbit::Listener::FromAdmin }
9
+ let(:exception_runner) { RubyRabbitmqJanus::Errors::Process::EventAdmin::Run }
10
+
11
+ include_examples 'when thread'
12
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe RubyRabbitmqJanus::Process::Concurrencies::Event, type: :thread,
6
+ name: :event do
7
+ let(:publish_name) { :publish }
8
+ let(:listener) { RubyRabbitmqJanus::Rabbit::Listener::From }
9
+ let(:exception_runner) { RubyRabbitmqJanus::Errors::Process::Event::Run }
10
+
11
+ include_examples 'when thread'
12
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ shared_examples 'when thread' do
4
+ let(:concurrency) { described_class }
5
+ let(:event) { concurrency.new }
6
+ let(:action) { EventTest.new.actions }
7
+ let(:size) { (rand * 10).to_i }
8
+
9
+ it { expect(concurrency::NAME_VAR).to be_a(Symbol) }
10
+ it { expect(concurrency::NAME_VAR).to eql(publish_name) }
11
+ it { expect(action).not_to be(nil) }
12
+ it { expect { event.run(&action) }.not_to raise_error(exception_runner) }
13
+ it { expect { event.run }.to raise_error(exception_runner) }
14
+
15
+ it do
16
+ ee = event
17
+
18
+ ee.run(&action)
19
+ expect(ee.send(:publisher)).to be_a(listener)
20
+ end
21
+
22
+ it do
23
+ (1..size).each { event.run(&action) }
24
+
25
+ expect(Thread.list.count { |thread| thread.status.eql?('run') }).to eql(size + 1)
26
+ end
27
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_rabbitmq_janus
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.pre.351
4
+ version: 3.0.0.pre.352
5
5
  platform: ruby
6
6
  authors:
7
7
  - VAILLANT Jeremy
@@ -467,7 +467,6 @@ files:
467
467
  - lib/rrj/errors/janus/transactions/handle.rb
468
468
  - lib/rrj/errors/janus/transactions/session.rb
469
469
  - lib/rrj/errors/janus/transactions/transaction.rb
470
- - lib/rrj/errors/process/concurency.rb
471
470
  - lib/rrj/errors/process/event.rb
472
471
  - lib/rrj/errors/process/event_admin.rb
473
472
  - lib/rrj/errors/rabbit/base_event.rb
@@ -589,6 +588,8 @@ files:
589
588
  - spec/ruby_rabbitmq_janus/models/janus_instance_definition_spec.rb
590
589
  - spec/ruby_rabbitmq_janus/models/janus_instance_spec.rb
591
590
  - spec/ruby_rabbitmq_janus/process/concurrencies/concurrency_spec.rb
591
+ - spec/ruby_rabbitmq_janus/process/concurrencies/event_admin_spec.rb
592
+ - spec/ruby_rabbitmq_janus/process/concurrencies/event_spec.rb
592
593
  - spec/ruby_rabbitmq_janus/rabbit/connect_spec.rb
593
594
  - spec/ruby_rabbitmq_janus/rabbit/listener/from_spec.rb
594
595
  - spec/ruby_rabbitmq_janus/rabbit/propertie_instance_classic_spec.rb
@@ -643,6 +644,7 @@ files:
643
644
  - spec/support/examples_base.rb
644
645
  - spec/support/examples_config.rb
645
646
  - spec/support/examples_message.rb
647
+ - spec/support/examples_thread.rb
646
648
  - spec/support/initialize_janus_instance.rb
647
649
  - spec/support/schemas/config/config.json
648
650
  - spec/support/schemas/config/rabbit_options_admin_instance_classic.json
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RubyRabbitmqJanus
4
- module Errors
5
- module Process
6
- # Define a super class for all error in Process::Concurency class
7
- class BaseConcurency < RubyRabbitmqJanus::Errors::RRJError
8
- def initialize(message)
9
- super "[Concurency]#{message}", :fatal
10
- end
11
- end
12
-
13
- # Define a super class for all error in Process::Concurency::Event class
14
- class BaseEvent < RubyRabbitmqJanus::Errors::Process::BaseConcurency
15
- def initialize(class_name, message)
16
- super "[#{class_name}] #{message}"
17
- end
18
- end
19
-
20
- module Concurency
21
- # Error for Process::Concurency#initialize
22
- class Initializer < RubyRabbitmqJanus::Errors::Process::BaseConcurency
23
- def initialize
24
- super 'Error initialize concurency class'
25
- end
26
- end
27
- end
28
- end
29
- end
30
- end
31
-
32
- require 'rrj/errors/process/event'
33
- require 'rrj/errors/process/event_admin'