legion-transport 1.1.3 → 1.1.9

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
  SHA256:
3
- metadata.gz: aca9d21a2d161f0838dc16ce328d81c3ba42360a777c63e6aa805f6c52502e13
4
- data.tar.gz: 46af9353894537c81d73a68e01522498181d6d2fb54ae3fcdec465ebb75f8675
3
+ metadata.gz: fb72f3f576877e0433cf8017779136a89fa4ab4d24576c27b3f189a91f9e6813
4
+ data.tar.gz: f0a0e71cfc51a5db33d38992b4db2aa19c4850ec9bad1e76760b15cb8f3f2066
5
5
  SHA512:
6
- metadata.gz: add6818532d2159f4fa2be2a40148694f24511f7ca5095ad4477c9e0b72d70c546b2c7ba7ce6b60b44fa9b538c64e08d032dede1f341bbcb6e1831f541828d0e
7
- data.tar.gz: 754b708ce889ff36ab763f4f72887895195721a9f5e43bea168e802ad6cde0e3fc813ef9ed7ac2e11d677388777d264fc635b57912376f96dff1b03d71108ce3
6
+ metadata.gz: fef7c669811ce5eff26f0a01556245511900f6eabc392d14c4eae5772e157e3aa108b4c3cbcf4d2dad6b028b8c51c9e8d314133fb9ab8b7c70450db63e229bfa
7
+ data.tar.gz: 58c648db5d56d71060b20f0e921805144e741ab2c5e063e70938b4f7965344e807d9a3b431805ced7b3e6fc912e2073eac56e13c64f34d52459bba47c9f0b805
@@ -1,7 +1,7 @@
1
1
  version: 2.1
2
2
  orbs:
3
- ruby: circleci/ruby@0.2.1
4
- sonarcloud: sonarsource/sonarcloud@1.0.1
3
+ ruby: circleci/ruby@1.1.2
4
+ sonarcloud: sonarsource/sonarcloud@1.0.2
5
5
 
6
6
  jobs:
7
7
  "rubocop":
@@ -9,65 +9,61 @@ jobs:
9
9
  - image: circleci/ruby:2.7-node
10
10
  steps:
11
11
  - checkout
12
- - ruby/load-cache
13
- - ruby/install-deps
14
- - run:
15
- name: Run Rubocop
16
- command: bundle exec rubocop
17
- - ruby/save-cache
12
+ - run: gem install bundler
13
+ - run: bundle update
14
+ - run: bundle exec rubocop --format=json --out=rubocop-result.json
15
+ - store_test_results:
16
+ path: rubocop-result.json
17
+ - sonarcloud/scan
18
+ - run: bundle exec rubocop
18
19
  "ruby-two-five":
19
20
  docker:
20
21
  - image: circleci/ruby:2.5
21
22
  - image: rabbitmq:3.7
22
23
  steps:
23
24
  - checkout
24
- - ruby/load-cache
25
- - run:
26
- name: update bundler
27
- command: gem update bundler
28
- - ruby/install-deps
29
- - ruby/run-tests
30
- - ruby/save-cache
25
+ - run: gem install bundler
26
+ - run: bundle update
27
+ - run: bundle exec rspec --format progress --format RspecJunitFormatter -o rspec-results.xml
28
+ - store_test_results:
29
+ path: rspec-results.xml
30
+ - sonarcloud/scan
31
31
  "ruby-two-six":
32
32
  docker:
33
33
  - image: circleci/ruby:2.6
34
34
  - image: rabbitmq:3.7
35
35
  steps:
36
36
  - checkout
37
- - ruby/load-cache
38
- - run:
39
- name: update bundler
40
- command: gem update bundler
41
- - ruby/install-deps
42
- - ruby/run-tests
43
- - ruby/save-cache
37
+ - run: gem install bundler
38
+ - run: bundle update
39
+ - run: bundle exec rspec --format progress --format RspecJunitFormatter -o rspec-results.xml
40
+ - store_test_results:
41
+ path: rspec-results.xml
42
+ - sonarcloud/scan
44
43
  "ruby-two-seven":
45
44
  docker:
46
45
  - image: circleci/ruby:2.7
47
46
  - image: rabbitmq:3.7
48
47
  steps:
49
48
  - checkout
50
- - ruby/load-cache
51
- - run:
52
- name: update bundler
53
- command: gem update bundler
54
- - ruby/install-deps
55
- - ruby/run-tests
56
- - ruby/save-cache
57
- "sonarcloud":
49
+ - run: gem install bundler
50
+ - run: bundle update
51
+ - run: bundle exec rspec --format progress --format RspecJunitFormatter -o rspec-results.xml
52
+ - store_test_results:
53
+ path: rspec-results.xml
54
+ - sonarcloud/scan
55
+ "ruby-three":
58
56
  docker:
59
- - image: circleci/ruby:2.7
57
+ - image: circleci/ruby:3-node
60
58
  - image: rabbitmq:3.7
61
59
  steps:
62
60
  - checkout
63
- - ruby/load-cache
64
- - ruby/install-deps
65
- - ruby/run-tests
66
- - run:
67
- name: Run Rubocop
68
- command: bundle exec rubocop --format=json --out=rubocop-result.json
61
+ - run: gem install bundler
62
+ - run: bundle update
63
+ - run: bundle exec rspec --format progress --format RspecJunitFormatter -o rspec-results.xml
64
+ - store_test_results:
65
+ path: rspec-results.xml
69
66
  - sonarcloud/scan
70
- - ruby/save-cache
71
67
 
72
68
  workflows:
73
69
  version: 2
@@ -83,7 +79,6 @@ workflows:
83
79
  - ruby-two-seven:
84
80
  requires:
85
81
  - ruby-two-five
86
- - sonarcloud:
82
+ - ruby-three:
87
83
  requires:
88
- - ruby-two-seven
89
- - ruby-two-six
84
+ - ruby-two-five
@@ -6,6 +6,12 @@ Metrics/ClassLength:
6
6
  Max: 1500
7
7
  Metrics/BlockLength:
8
8
  Max: 50
9
+ Exclude:
10
+ - 'spec/*/**.rb'
11
+ Metrics/PerceivedComplexity:
12
+ Max: 15
13
+ Metrics/CyclomaticComplexity:
14
+ Max: 15
9
15
  Layout/SpaceAroundEqualsInParameterDefault:
10
16
  EnforcedStyle: space
11
17
  Style/SymbolArray:
@@ -15,6 +21,7 @@ Style/Documentation:
15
21
  AllCops:
16
22
  TargetRubyVersion: 2.5
17
23
  NewCops: enable
24
+ SuggestExtensions: false
18
25
  Style/FrozenStringLiteralComment:
19
26
  Enabled: false
20
27
  Naming/FileName:
@@ -1,5 +1,27 @@
1
1
  # Legion::Transport ChangeLog
2
2
 
3
+ ## v1.1.9
4
+ * Adding new setting `transport.channel.default_worker_pool_size = 1` for whenever a new channel is created
5
+ * Adding new setting `transport.channel.session_worker_pool_size = 1` for default session channel
6
+ * Making the following settings setable with env variables
7
+ - transport.prefetch
8
+ - transport.logger_level
9
+ - transport.channel.default_worker_pool_size
10
+ - transport.channel.session_worker_pool_size
11
+ - transport.connection.user
12
+ - transport.connection.password
13
+ - transport.connection.host
14
+ - transport.connection.port
15
+ - transport.connection.vhost
16
+
17
+ ## v1.1.8
18
+ * Removing codecov gem
19
+ * Changing bunny gem requirement to `>= 2.17.0`
20
+ * Changing current-ruby gem requirement to `>= 1.1.7`
21
+ * Removing JRuby support
22
+ * Removing bin/ folder
23
+ * Cleaning up some channel objects inside Messages and Queues
24
+
3
25
  ## v1.1.3
4
26
  * Adding JRuby support via a different gem
5
27
  * Adding more logic on choosing which gem to pick for the CONNECTOR
@@ -1,24 +1,14 @@
1
- image: ruby:2.5.0
1
+ image: ruby:2.7
2
2
 
3
3
  pipelines:
4
- branches:
5
- master:
6
- - step:
7
- caches:
8
- - bundler
9
- script:
10
- - gem install bundle rubocop
11
- - bundle install
12
- - rubocop
13
- - rake
14
- services:
15
- - broker
16
- definitions:
17
- caches:
18
- bundler: vendor/bundle
19
- services:
20
- broker:
21
- image: rabbitmq:3
22
- environment:
23
- RABBITMQ_DEFAULT_USER: guest
24
- RABBITMQ_DEFAULT_PASS: guest
4
+ tags:
5
+ "v*":
6
+ - step:
7
+ name: Push to RubyGems
8
+ deployment: RubyGems
9
+ script:
10
+ - gem install gem-release
11
+ - (umask 077 ; echo $gem_creds | base64 --decode > ~/.gem/credentials)
12
+ - gem release
13
+ artifacts:
14
+ - pkg/**
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'legion/transport/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = (RUBY_ENGINE == 'jruby' ? 'legion-transport-java' : 'legion-transport')
6
+ spec.name = 'legion-transport'
7
7
  spec.version = Legion::Transport::VERSION
8
8
  spec.authors = ['Esity']
9
9
  spec.email = ['matthewdiverson@gmail.com']
@@ -23,21 +23,18 @@ Gem::Specification.new do |spec|
23
23
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
24
24
  f.match(%r{^(test|spec|features)/})
25
25
  end
26
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
26
  spec.require_paths = ['lib']
28
27
 
29
- spec.add_development_dependency 'bundler'
30
- spec.add_development_dependency 'codecov'
31
28
  spec.add_development_dependency 'legion-logging'
32
29
  spec.add_development_dependency 'legion-settings'
33
- spec.add_development_dependency 'march_hare' if RUBY_ENGINE == 'jruby'
34
30
  spec.add_development_dependency 'rake'
35
31
  spec.add_development_dependency 'rspec'
36
32
  spec.add_development_dependency 'rspec_junit_formatter'
37
33
  spec.add_development_dependency 'rubocop'
38
34
  spec.add_development_dependency 'simplecov'
35
+ spec.add_development_dependency 'simplecov_json_formatter'
39
36
 
40
- spec.add_dependency 'bunny'
41
- spec.add_dependency 'concurrent-ruby'
37
+ spec.add_dependency 'bunny', '>= 2.17.0'
38
+ spec.add_dependency 'concurrent-ruby', '>= 1.1.7'
42
39
  spec.add_dependency 'legion-json'
43
40
  end
@@ -3,11 +3,11 @@ require_relative 'transport/settings'
3
3
 
4
4
  module Legion
5
5
  module Transport
6
- if RUBY_ENGINE == 'jruby' && defined?(::Marchhare)
7
- require 'marchhare'
8
- TYPE = 'marchhare'.freeze
9
- CONNECTOR = ::Marchhare
10
- else
6
+ begin
7
+ require 'march_hare'
8
+ TYPE = 'march_hare'.freeze
9
+ CONNECTOR = ::MarchHare
10
+ rescue LoadError
11
11
  require 'bunny'
12
12
  TYPE = 'bunny'.freeze
13
13
  CONNECTOR = ::Bunny
@@ -17,6 +17,5 @@ module Legion
17
17
  require_relative 'transport/common'
18
18
  require_relative 'transport/queue'
19
19
  require_relative 'transport/exchange'
20
- require_relative 'transport/consumer'
21
20
  require_relative 'transport/message'
22
21
  end
@@ -4,35 +4,83 @@ module Legion
4
4
  module Transport
5
5
  module Connection
6
6
  class << self
7
+ def settings
8
+ Legion::Settings[:transport]
9
+ end
10
+
11
+ def new
12
+ clone
13
+ end
14
+
7
15
  def connector
8
16
  Legion::Transport::CONNECTOR
9
17
  end
10
18
 
11
- def setup # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
19
+ def reconnect(connection_name: 'Legion', **)
20
+ @session = nil
21
+ @channel_thread = Concurrent::ThreadLocalVar.new(nil)
22
+ setup(connection_name: connection_name)
23
+ end
24
+
25
+ def setup(connection_name: 'Legion', **) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
26
+ Legion::Logging.info("Using transport connector: #{Legion::Transport::CONNECTOR}")
27
+
12
28
  if @session.respond_to?(:value) && session.respond_to?(:closed?) && session.closed?
13
- @channel_thread = Concurrent::ThreadLocalVar.new
29
+ @channel_thread = Concurrent::ThreadLocalVar.new(nil)
14
30
  elsif @session.respond_to?(:value) && session.respond_to?(:closed?) && session.open?
15
- return nil
31
+ nil
32
+ elsif Legion::Transport::TYPE == 'march_hare'
33
+ @session ||= Concurrent::AtomicReference.new(
34
+ MarchHare.connect(host: settings[:connection][:host],
35
+ vhost: settings[:connection][:vhost],
36
+ user: settings[:connection][:user],
37
+ password: settings[:connection][:password],
38
+ port: settings[:connection][:port])
39
+ )
40
+ @channel_thread = Concurrent::ThreadLocalVar.new(nil)
41
+ session.start
42
+ session.create_channel.basic_qos(settings[:prefetch])
43
+ Legion::Settings[:transport][:connected] = true
16
44
  else
17
- @session ||= Concurrent::Atom.new(
45
+ @session ||= Concurrent::AtomicReference.new(
18
46
  connector.new(
19
47
  Legion::Settings[:transport][:connection],
48
+ connection_name: connection_name,
20
49
  logger: Legion::Logging::Logger.new(level: 'warn'),
21
50
  log_level: :info
22
51
  )
23
52
  )
24
- @channel_thread = Concurrent::ThreadLocalVar.new
53
+ @channel_thread = Concurrent::ThreadLocalVar.new(nil)
54
+ session.start
55
+ session.create_channel(nil, settings[:channel][:session_worker_pool_size])
56
+ .basic_qos(settings[:prefetch], true)
57
+ Legion::Settings[:transport][:connected] = true
25
58
  end
26
59
 
27
- session.start
28
- session.create_channel.basic_qos(1, true)
60
+ if session.respond_to? :on_blocked
61
+ session.on_blocked { Legion::Logging.warn('Legion::Transport is being blocked by RabbitMQ!') }
62
+ end
63
+
64
+ if session.respond_to? :on_unblocked
65
+ session.on_unblocked { Legion::Logging.info('Legion::Transport is no longer being blocked by RabbitMQ') }
66
+ end
67
+
68
+ if session.respond_to? :after_recovery_completed
69
+ session.after_recovery_completed { Legion::Logging.info('Legion::Transport has completed recovery') }
70
+ end
71
+
72
+ true
29
73
  end
30
74
 
31
- def channel
75
+ def channel # rubocop:disable Metrics/AbcSize
32
76
  return @channel_thread.value if !@channel_thread.value.nil? && @channel_thread.value.open?
33
77
 
34
- @channel_thread.value = session.create_channel
35
- @channel_thread.value.prefetch(Legion::Settings[:transport][:prefetch])
78
+ @channel_thread.value = session.create_channel(nil, settings[:channel][:default_worker_pool_size], false, 10)
79
+ if Legion::Transport::TYPE == 'march_hare'
80
+ @channel_thread.value.basic_qos(settings[:prefetch])
81
+ else
82
+ @channel_thread.value.prefetch(settings[:prefetch])
83
+ end
36
84
  @channel_thread.value
37
85
  end
38
86
 
@@ -47,14 +95,19 @@ module Legion
47
95
 
48
96
  def channel_open?
49
97
  channel.open?
98
+ rescue StandardError
99
+ false
50
100
  end
51
101
 
52
102
  def session_open?
53
103
  session.open?
104
+ rescue StandardError
105
+ false
54
106
  end
55
107
 
56
108
  def shutdown
57
109
  session.close
110
+ @session = nil
58
111
  end
59
112
  end
60
113
  end
@@ -6,8 +6,14 @@ module Legion
6
6
  def initialize(exchange = exchange_name, options = {})
7
7
  @options = options
8
8
  @type = options[:type] || default_type
9
- super(channel, @type, exchange, options_builder(default_options, exchange_options, @options))
10
- rescue ::Bunny::PreconditionFailed, ::Bunny::ChannelAlreadyClosed
9
+ if Legion::Transport::TYPE == 'march_hare'
10
+ super_options = options_builder(default_options, exchange_options, @options)
11
+ super_options[:type] = @type
12
+ super(channel, exchange, **super_options)
13
+ else
14
+ super(channel, @type, exchange, options_builder(default_options, exchange_options, @options))
15
+ end
16
+ rescue Legion::Transport::CONNECTOR::PreconditionFailed, Legion::Transport::CONNECTOR::ChannelAlreadyClosed
11
17
  raise unless @retries.nil?
12
18
 
13
19
  @retries = 1
@@ -21,7 +27,7 @@ module Legion
21
27
  end
22
28
 
23
29
  def default_options
24
- hash = {}
30
+ hash = Concurrent::Hash.new
25
31
  hash[:durable] = true
26
32
  hash[:auto_delete] = false
27
33
  hash[:arguments] = {}
@@ -33,19 +39,23 @@ module Legion
33
39
  end
34
40
 
35
41
  def exchange_options
36
- {}
42
+ Concurrent::Hash.new
37
43
  end
38
44
 
39
45
  def delete(options = {})
40
46
  super(options)
41
47
  true
42
- rescue ::Bunny::PreconditionFailed
48
+ rescue Legion::Transport::CONNECTOR::PreconditionFailed
43
49
  false
44
50
  end
45
51
 
46
52
  def default_type
47
53
  'topic'
48
54
  end
55
+
56
+ def channel
57
+ Legion::Transport::Connection.channel
58
+ end
49
59
  end
50
60
  end
51
61
  end
@@ -8,7 +8,7 @@ module Legion
8
8
  validate
9
9
  end
10
10
 
11
- def publish(options = @options) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
11
+ def publish(options = @options) # rubocop:disable Metrics/AbcSize
12
12
  raise unless @valid
13
13
 
14
14
  exchange_dest = exchange.respond_to?(:new) ? exchange.new : exchange
@@ -22,10 +22,22 @@ module Legion
22
22
  headers: headers)
23
23
  end
24
24
 
25
+ def expiration
26
+ if @options.key? :expiration
27
+ @options[:expiration]
28
+ elsif @options.key? :ttl
29
+ @options[:ttl]
30
+ end
31
+ end
32
+
25
33
  def message
26
34
  @options
27
35
  end
28
36
 
37
+ def routing_key
38
+ @options[:routing_key] if @options.key? :routing_key
39
+ end
40
+
29
41
  def encode_message
30
42
  message_payload = message
31
43
  message_payload = Legion::JSON.dump(message_payload) unless message_payload.is_a? String
@@ -60,7 +72,7 @@ module Legion
60
72
  end
61
73
 
62
74
  def headers
63
- @options[:headers] ||= {}
75
+ @options[:headers] ||= Concurrent::Hash.new
64
76
  %i[task_id relationship_id trigger_namespace_id trigger_function_id parent_id master_id runner_namespace runner_class namespace_id function_id function chain_id debug].each do |header| # rubocop:disable Layout/LineLength
65
77
  next unless @options.key? header
66
78
 
@@ -76,10 +88,6 @@ module Legion
76
88
  0
77
89
  end
78
90
 
79
- def expiration
80
- nil
81
- end
82
-
83
91
  def content_type
84
92
  'application/json'
85
93
  end
@@ -99,6 +107,10 @@ module Legion
99
107
  def validate
100
108
  @valid = true
101
109
  end
110
+
111
+ def channel
112
+ Legion::Transport::Connection.channel
113
+ end
102
114
  end
103
115
  end
104
116
  end
@@ -7,7 +7,8 @@ module Legion::Transport::Messages # rubocop:disable Style/ClassAndModuleChildre
7
7
  end
8
8
 
9
9
  def message
10
- { args: @options[:args] || @options }
10
+ { args: @options[:args] || @options,
11
+ function: function.values[:name] }
11
12
  end
12
13
 
13
14
  def routing_key
@@ -0,0 +1,41 @@
1
+ module Legion
2
+ module Transport
3
+ module Messages
4
+ class Task < Legion::Transport::Message
5
+ def exchange
6
+ if @options.key?(:exchange) && @options[:exchange].is_a?(String)
7
+ Legion::Transport::Exchanges.new(@options[:exchange])
8
+ else
9
+ Legion::Transport::Exchanges::Task.new
10
+ end
11
+ end
12
+
13
+ def message
14
+ @options
15
+ end
16
+
17
+ def routing_key # rubocop:disable Metrics/AbcSize
18
+ if @options.key? :routing_key
19
+ @options[:routing_key]
20
+ elsif @options[:conditions].is_a?(String) && @options[:conditions].length > 2
21
+ 'task.subtask.conditioner'
22
+ elsif @options[:transformation].is_a?(String) && @options[:transformation].length > 2
23
+ 'task.subtask.transform'
24
+ elsif @options[:queue].is_a?(String) && @options[:function].is_a?(String)
25
+ "#{@options[:queue]}.#{@options[:function]}"
26
+ elsif @options[:queue].is_a?(String) && @options[:function_name].is_a?(String)
27
+ "#{@options[:queue]}.#{@options[:function_name]}"
28
+ elsif @options[:queue].is_a?(String) && @options[:name].is_a?(String)
29
+ "#{@options[:queue]}.#{@options[:name]}"
30
+ end
31
+ end
32
+
33
+ def validate
34
+ raise TypeError unless @options[:function].is_a? String
35
+
36
+ @valid = true
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -2,8 +2,13 @@ require 'legion/transport/exchanges/task'
2
2
 
3
3
  module Legion
4
4
  module Exception
5
- class InvalidTaskStatus; end
6
- class InvalidTaskId; end
5
+ class InvalidTaskStatus < ArgumentError
6
+ # exception class
7
+ end
8
+
9
+ class InvalidTaskId < ArgumentError
10
+ # exception class
11
+ end
7
12
  end
8
13
  end
9
14
 
@@ -7,20 +7,20 @@ module Legion
7
7
  retries ||= 0
8
8
  @options = options
9
9
  super(channel, queue, options_builder(default_options, queue_options, options))
10
- rescue ::Bunny::PreconditionFailed
10
+ rescue Legion::Transport::CONNECTOR::PreconditionFailed
11
11
  retries.zero? ? retries = 1 : raise
12
- recreate_queue(channel, queue)
12
+ recreate_queue(queue)
13
13
  retry
14
14
  end
15
15
 
16
- def recreate_queue(channel, queue)
16
+ def recreate_queue(queue)
17
17
  Legion::Logging.warn "Queue:#{queue} exists with wrong parameters, deleting and creating"
18
- queue = ::Bunny::Queue.new(channel, queue, no_declare: true, passive: true)
18
+ queue = ::Bunny::Queue.new(Legion::Transport::Connection.channel, queue, no_declare: true, passive: true)
19
19
  queue.delete(if_empty: true)
20
20
  end
21
21
 
22
22
  def default_options
23
- hash = {}
23
+ hash = Concurrent::Hash.new
24
24
  hash[:manual_ack] = true
25
25
  hash[:durable] = true
26
26
  hash[:exclusive] = false
@@ -35,7 +35,7 @@ module Legion
35
35
  end
36
36
 
37
37
  def queue_options
38
- {}
38
+ Concurrent::Hash.new
39
39
  end
40
40
 
41
41
  def queue_name
@@ -51,7 +51,7 @@ module Legion
51
51
  def delete(options = { if_unused: true, if_empty: true })
52
52
  super(options)
53
53
  true
54
- rescue ::Bunny::PreconditionFailed
54
+ rescue Legion::Transport::CONNECTOR::PreconditionFailed
55
55
  false
56
56
  end
57
57
 
@@ -3,22 +3,23 @@ require 'legion/settings'
3
3
  module Legion
4
4
  module Transport
5
5
  module Settings
6
- # Legion::Settings.merge_settings('transport', default) if Legion::Settings.method_defined? :merge_settings
7
6
  def self.connection
8
7
  {
9
8
  read_timeout: 1,
10
- heartbeat: 1,
9
+ heartbeat: 30,
11
10
  automatically_recover: true,
12
11
  continuation_timeout: 4000,
13
12
  network_recovery_interval: 1,
14
13
  connection_timeout: 1,
15
- user: 'guest',
16
- password: 'guest',
17
- host: '127.0.0.1',
18
- port: '5672',
19
- vhost: '/',
20
- recovery_attempts: 0,
21
- logger_level: 'info'
14
+ frame_max: 65_536,
15
+ user: ENV['transport.connection.user'] || 'guest',
16
+ password: ENV['transport.connection.password'] || 'guest',
17
+ host: ENV['transport.connection.host'] || '127.0.0.1',
18
+ port: ENV['transport.connection.port'] || '5672',
19
+ vhost: ENV['transport.connection.vhost'] || '/',
20
+ recovery_attempts: 100,
21
+ logger_level: ENV['transport.log_level'] || 'info',
22
+ connected: false
22
23
  }.merge(grab_vault_creds)
23
24
  end
24
25
 
@@ -32,33 +33,49 @@ module Legion
32
33
  {}
33
34
  end
34
35
 
36
+ def self.channel
37
+ {
38
+ default_worker_pool_size: ENV['transport.channel.default_worker_pool_size'] || 1,
39
+ session_worker_pool_size: ENV['transport.channel.session_worker_pool_size'] || 8
40
+ }
41
+ end
42
+
43
+ def self.queues
44
+ {
45
+ manual_ack: true,
46
+ durable: true,
47
+ exclusive: false,
48
+ block: false,
49
+ auto_delete: false,
50
+ arguments: { 'x-max-priority': 255, 'x-overflow': 'reject-publish' }
51
+ }
52
+ end
53
+
54
+ def self.exchanges
55
+ {
56
+ type: 'topic',
57
+ arguments: {},
58
+ auto_delete: false,
59
+ durable: true,
60
+ internal: false
61
+ }
62
+ end
63
+
35
64
  def self.default
36
65
  {
37
66
  type: 'rabbitmq',
38
67
  connected: false,
39
- logger_level: 'info',
68
+ logger_level: ENV['transport.logger_level'] || 'info',
40
69
  messages: {
41
70
  encrypt: false,
42
71
  ttl: nil,
43
72
  priority: 0
44
73
  },
45
- exchanges: {
46
- type: 'topic',
47
- arguments: {},
48
- auto_delete: false,
49
- durable: true,
50
- internal: false
51
- },
52
- queues: {
53
- manual_ack: true,
54
- durable: true,
55
- exclusive: false,
56
- block: false,
57
- auto_delete: false,
58
- arguments: { 'x-max-priority': 255, 'x-overflow': 'reject-publish' }
59
- },
60
- prefetch: 2,
61
- connection: connection
74
+ prefetch: ENV['transport.prefetch'].to_i || 2,
75
+ exchanges: exchanges,
76
+ queues: queues,
77
+ connection: connection,
78
+ channel: channel
62
79
  }
63
80
  end
64
81
  end
@@ -1,5 +1,5 @@
1
1
  module Legion
2
2
  module Transport
3
- VERSION = '1.1.3'.freeze
3
+ VERSION = '1.1.9'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,31 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legion-transport
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-25 00:00:00.000000000 Z
11
+ date: 2021-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: codecov
14
+ name: legion-logging
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - ">="
@@ -39,7 +25,7 @@ dependencies:
39
25
  - !ruby/object:Gem::Version
40
26
  version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
- name: legion-logging
28
+ name: legion-settings
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - ">="
@@ -53,7 +39,7 @@ dependencies:
53
39
  - !ruby/object:Gem::Version
54
40
  version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
- name: legion-settings
42
+ name: rake
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - ">="
@@ -67,7 +53,7 @@ dependencies:
67
53
  - !ruby/object:Gem::Version
68
54
  version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
- name: rake
56
+ name: rspec
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - ">="
@@ -81,7 +67,7 @@ dependencies:
81
67
  - !ruby/object:Gem::Version
82
68
  version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
- name: rspec
70
+ name: rspec_junit_formatter
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - ">="
@@ -95,7 +81,7 @@ dependencies:
95
81
  - !ruby/object:Gem::Version
96
82
  version: '0'
97
83
  - !ruby/object:Gem::Dependency
98
- name: rspec_junit_formatter
84
+ name: rubocop
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
87
  - - ">="
@@ -109,7 +95,7 @@ dependencies:
109
95
  - !ruby/object:Gem::Version
110
96
  version: '0'
111
97
  - !ruby/object:Gem::Dependency
112
- name: rubocop
98
+ name: simplecov
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
101
  - - ">="
@@ -123,7 +109,7 @@ dependencies:
123
109
  - !ruby/object:Gem::Version
124
110
  version: '0'
125
111
  - !ruby/object:Gem::Dependency
126
- name: simplecov
112
+ name: simplecov_json_formatter
127
113
  requirement: !ruby/object:Gem::Requirement
128
114
  requirements:
129
115
  - - ">="
@@ -142,28 +128,28 @@ dependencies:
142
128
  requirements:
143
129
  - - ">="
144
130
  - !ruby/object:Gem::Version
145
- version: '0'
131
+ version: 2.17.0
146
132
  type: :runtime
147
133
  prerelease: false
148
134
  version_requirements: !ruby/object:Gem::Requirement
149
135
  requirements:
150
136
  - - ">="
151
137
  - !ruby/object:Gem::Version
152
- version: '0'
138
+ version: 2.17.0
153
139
  - !ruby/object:Gem::Dependency
154
140
  name: concurrent-ruby
155
141
  requirement: !ruby/object:Gem::Requirement
156
142
  requirements:
157
143
  - - ">="
158
144
  - !ruby/object:Gem::Version
159
- version: '0'
145
+ version: 1.1.7
160
146
  type: :runtime
161
147
  prerelease: false
162
148
  version_requirements: !ruby/object:Gem::Requirement
163
149
  requirements:
164
150
  - - ">="
165
151
  - !ruby/object:Gem::Version
166
- version: '0'
152
+ version: 1.1.7
167
153
  - !ruby/object:Gem::Dependency
168
154
  name: legion-json
169
155
  requirement: !ruby/object:Gem::Requirement
@@ -191,10 +177,9 @@ files:
191
177
  - ".rubocop.yml"
192
178
  - CHANGELOG.md
193
179
  - Gemfile
180
+ - Gemfile.lock
194
181
  - README.md
195
182
  - Rakefile
196
- - bin/console
197
- - bin/setup
198
183
  - bitbucket-pipelines.yml
199
184
  - legion-transport.gemspec
200
185
  - lib/legion/transport.rb
@@ -213,6 +198,7 @@ files:
213
198
  - lib/legion/transport/messages/node_health.rb
214
199
  - lib/legion/transport/messages/request_cluster_secret.rb
215
200
  - lib/legion/transport/messages/subtask.rb
201
+ - lib/legion/transport/messages/task.rb
216
202
  - lib/legion/transport/messages/task_log.rb
217
203
  - lib/legion/transport/messages/task_update.rb
218
204
  - lib/legion/transport/queue.rb
@@ -232,7 +218,7 @@ metadata:
232
218
  changelog_uri: https://bitbucket.org/legion-io/legion-transport/src/master/CHANGELOG.md
233
219
  homepage_uri: https://bitbucket.org/legion-io/legion-transport
234
220
  wiki_uri: https://bitbucket.org/legion-io/legion-transport/wiki/Home
235
- post_install_message:
221
+ post_install_message:
236
222
  rdoc_options: []
237
223
  require_paths:
238
224
  - lib
@@ -247,8 +233,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
247
233
  - !ruby/object:Gem::Version
248
234
  version: '0'
249
235
  requirements: []
250
- rubygems_version: 3.1.2
251
- signing_key:
236
+ rubygems_version: 3.1.4
237
+ signing_key:
252
238
  specification_version: 4
253
239
  summary: Used by Legion to connect with RabbitMQ
254
240
  test_files: []
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bundler/setup'
4
- require 'legion/transport'
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require 'irb'
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here