legion-transport 1.0.0 → 1.1.4

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: 4b8ebe4ac7e742ce233b6a34093a8b98d9edae6fd93a15bc1f0de46aedd0ae03
4
- data.tar.gz: 24574a28c192e3f79da7b36b33e19de1b93550162f58ecdd0df136892a7aee1d
3
+ metadata.gz: a14303eeb59f5d328dba4782a6fcab96087a63403fa7e734fa98738c6010fccd
4
+ data.tar.gz: 3c30d91267de37a9f04e721755dd5452a9dcb8c6ff649c9a17ce0b941893be5d
5
5
  SHA512:
6
- metadata.gz: 4b956aeca717ed356ea934f07f2a3ec58ae30da3d5b3aa3fe39b6e2968cda9f0ee42843751abefa120942c4ffd2df7f4f53bdd8cb5bb51c05e91ac65200d4299
7
- data.tar.gz: 6165b84e313abce9a15e7126e6cae813323bc3ac4969bf8c7aba2e72c6e201e8d864e47d9125dfe8c216f78a50a728f7898634de20fd2967e532c7955637d4da
6
+ metadata.gz: b4e78c019c6ae475aa18cb82108c024d9df78f84d46073cdfcbbffafc2b1ac393e255052f4036a3311f652f01269aa1cfe7e636b6153c30b0c32cf11825e4622
7
+ data.tar.gz: f42031b318d1e491fff023496c379c323e8ec81aebe750d0291b8bdf0b6c1f361fd99b0d60804ba0814023b560f2e6ca3c76c00e845472cbf60ba54a9fbdc97e
@@ -1,116 +1,89 @@
1
- version: 2 # use CircleCI 2.0
1
+ version: 2.1
2
+ orbs:
3
+ ruby: circleci/ruby@0.2.1
4
+ sonarcloud: sonarsource/sonarcloud@1.0.1
5
+
2
6
  jobs:
3
7
  "rubocop":
4
8
  docker:
5
- - image: circleci/ruby:2.4-node
9
+ - image: circleci/ruby:2.7-node
6
10
  steps:
7
11
  - checkout
8
- - run: gem install rubocop
12
+ - ruby/load-cache
13
+ - ruby/install-deps
9
14
  - run:
10
15
  name: Run Rubocop
11
- command: rubocop
12
- - store_test_results:
13
- path: test_results
14
- "ruby-two-three":
16
+ command: bundle exec rubocop
17
+ - ruby/save-cache
18
+ "ruby-two-five":
15
19
  docker:
16
- - image: circleci/ruby:2.3
20
+ - image: circleci/ruby:2.5
17
21
  - image: rabbitmq:3.7
18
22
  steps:
19
23
  - checkout
24
+ - ruby/load-cache
20
25
  - run:
21
- name: Bundle Install
22
- command: bundle install
23
- - run:
24
- name: Run RSpec
25
- command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
26
- when: always
27
- - store_test_results:
28
- path: test-results
29
-
30
- "ruby-two-four":
26
+ name: update bundler
27
+ command: gem update bundler
28
+ - ruby/install-deps
29
+ - ruby/run-tests
30
+ - ruby/save-cache
31
+ "ruby-two-six":
31
32
  docker:
32
- - image: circleci/ruby:2.4-node
33
+ - image: circleci/ruby:2.6
33
34
  - image: rabbitmq:3.7
34
35
  steps:
35
36
  - checkout
37
+ - ruby/load-cache
36
38
  - run:
37
- name: Bundle Install
38
- command: bundle install
39
- - run:
40
- name: Run RSpec
41
- command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
42
- when: always
43
- - store_test_results:
44
- path: test-results
45
- "ruby-two-five":
39
+ name: update bundler
40
+ command: gem update bundler
41
+ - ruby/install-deps
42
+ - ruby/run-tests
43
+ - ruby/save-cache
44
+ "ruby-two-seven":
46
45
  docker:
47
- - image: circleci/ruby:2.5-node
46
+ - image: circleci/ruby:2.7
48
47
  - image: rabbitmq:3.7
49
48
  steps:
50
49
  - checkout
50
+ - ruby/load-cache
51
51
  - run:
52
- name: Bundle Install
53
- command: bundle install
54
- - run:
55
- name: Run RSpec
56
- command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
57
- when: always
58
- - store_test_results:
59
- path: test-results
60
- "ruby-two-six":
52
+ name: update bundler
53
+ command: gem update bundler
54
+ - ruby/install-deps
55
+ - ruby/run-tests
56
+ - ruby/save-cache
57
+ "sonarcloud":
61
58
  docker:
62
- - image: circleci/ruby:2.6-node
59
+ - image: circleci/ruby:2.7
63
60
  - image: rabbitmq:3.7
64
61
  steps:
65
62
  - checkout
63
+ - ruby/load-cache
64
+ - ruby/install-deps
65
+ - ruby/run-tests
66
66
  - run:
67
- name: Bundle Install
68
- command: bundle install
69
- - run:
70
- name: Run RSpec
71
- command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
72
- when: always
73
- - store_test_results:
74
- path: test-results
75
- "jruby-nine-two":
76
- docker:
77
- - image: circleci/jruby:9.2
78
- - image: rabbitmq:3.7
79
- steps:
80
- - checkout
81
- - run:
82
- name: Bundle Install
83
- command: bundle install
84
- - run:
85
- name: Run RSpec
86
- command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
87
- when: always
88
- - store_test_results:
89
- path: test-results
67
+ name: Run Rubocop
68
+ command: bundle exec rubocop --format=json --out=rubocop-result.json
69
+ - sonarcloud/scan
70
+ - ruby/save-cache
90
71
 
91
72
  workflows:
92
73
  version: 2
93
- cop_rake_deploy:
74
+ rubocop-rspec:
94
75
  jobs:
95
76
  - rubocop
96
- - ruby-two-three:
97
- requires:
98
- - ruby-two-four
99
- filters:
100
- branches:
101
- only: /\bdevelop\b|\bmaster\b/
102
- - ruby-two-four:
103
- requires:
104
- - rubocop
105
77
  - ruby-two-five:
106
78
  requires:
107
- - ruby-two-four
108
- filters:
109
- branches:
110
- only: /\bdevelop\b|\bmaster\b/
79
+ - rubocop
111
80
  - ruby-two-six:
112
81
  requires:
113
- - ruby-two-four
114
- filters:
115
- branches:
116
- only: /\bdevelop\b|\bmaster\b/
82
+ - ruby-two-five
83
+ - ruby-two-seven:
84
+ requires:
85
+ - ruby-two-five
86
+ - sonarcloud:
87
+ requires:
88
+ - ruby-two-seven
89
+ - ruby-two-six
@@ -1,4 +1,4 @@
1
- Metrics/LineLength:
1
+ Layout/LineLength:
2
2
  Max: 120
3
3
  Metrics/MethodLength:
4
4
  Max: 30
@@ -14,6 +14,7 @@ Style/Documentation:
14
14
  Enabled: false
15
15
  AllCops:
16
16
  TargetRubyVersion: 2.5
17
+ NewCops: enable
17
18
  Style/FrozenStringLiteralComment:
18
19
  Enabled: false
19
20
  Naming/FileName:
@@ -0,0 +1,9 @@
1
+ # Legion::Transport ChangeLog
2
+
3
+ ## v1.1.3
4
+ * Adding JRuby support via a different gem
5
+ * Adding more logic on choosing which gem to pick for the CONNECTOR
6
+ * Cleaning up some rubocop things
7
+
8
+ ## v1.1.2
9
+ Updating queue auto_delete to be false
data/README.md CHANGED
@@ -1,35 +1,3 @@
1
1
  # Legion::Transport
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/legion/transport`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'legion-transport'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install legion-transport
22
-
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
34
-
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/legion-transport.
3
+ Used to connect Legion to RabbitMQ and is a core component of Legion.
@@ -1,4 +1,4 @@
1
- image: ruby:2.4.0
1
+ image: ruby:2.5.0
2
2
 
3
3
  pipelines:
4
4
  branches:
@@ -11,6 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.summary = 'Used by Legion to connect with RabbitMQ'
12
12
  spec.description = 'The Legion transport gem'
13
13
  spec.homepage = 'https://bitbucket.org/legion-io/legion-transport'
14
+ spec.required_ruby_version = '>= 2.5.0'
14
15
 
15
16
  spec.metadata = {
16
17
  'bug_tracker_uri' => 'https://legionio.atlassian.net/projects/TRANSPORT/issues',
@@ -22,27 +23,21 @@ Gem::Specification.new do |spec|
22
23
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
23
24
  f.match(%r{^(test|spec|features)/})
24
25
  end
25
- spec.bindir = 'exe'
26
26
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
27
  spec.require_paths = ['lib']
28
28
 
29
29
  spec.add_development_dependency 'bundler'
30
30
  spec.add_development_dependency 'codecov'
31
- spec.add_development_dependency 'rake', '~> 10.0'
32
- spec.add_development_dependency 'rspec', '~> 3.0'
31
+ spec.add_development_dependency 'legion-logging'
32
+ spec.add_development_dependency 'legion-settings'
33
+ spec.add_development_dependency 'march_hare' if RUBY_ENGINE == 'jruby'
34
+ spec.add_development_dependency 'rake'
35
+ spec.add_development_dependency 'rspec'
33
36
  spec.add_development_dependency 'rspec_junit_formatter'
34
37
  spec.add_development_dependency 'rubocop'
35
38
  spec.add_development_dependency 'simplecov'
36
- spec.add_dependency 'concurrent-ruby'
37
- spec.add_dependency 'concurrent-ruby-ext'
38
-
39
- if RUBY_ENGINE == 'jruby'
40
- spec.add_development_dependency 'legion-settings-java'
41
- spec.add_dependency 'march_hare'
42
- else
43
- spec.add_development_dependency 'legion-settings'
44
- spec.add_dependency 'bunny'
45
- end
46
39
 
47
- spec.add_development_dependency 'legion-logging'
40
+ spec.add_dependency 'bunny'
41
+ spec.add_dependency 'concurrent-ruby'
42
+ spec.add_dependency 'legion-json'
48
43
  end
@@ -3,11 +3,11 @@ require_relative 'transport/settings'
3
3
 
4
4
  module Legion
5
5
  module Transport
6
- if RUBY_ENGINE == 'jruby'
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
@@ -8,30 +8,61 @@ module Legion
8
8
  Legion::Transport::CONNECTOR
9
9
  end
10
10
 
11
- def setup
11
+ def setup # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
12
+ Legion::Logging.info("Using transport connector: #{Legion::Transport::CONNECTOR}")
13
+
12
14
  if @session.respond_to?(:value) && session.respond_to?(:closed?) && session.closed?
13
- @channel_thread = Concurrent::ThreadLocalVar.new
15
+ @channel_thread = Concurrent::ThreadLocalVar.new(nil)
14
16
  elsif @session.respond_to?(:value) && session.respond_to?(:closed?) && session.open?
15
- return nil
17
+ nil
18
+ elsif Legion::Transport::TYPE == 'march_hare'
19
+ @session ||= Concurrent::Atom.new(
20
+ MarchHare.connect(host: Legion::Settings[:transport][:connection][:host],
21
+ vhost: Legion::Settings[:transport][:connection][:vhost],
22
+ user: Legion::Settings[:transport][:connection][:user],
23
+ password: Legion::Settings[:transport][:connection][:password],
24
+ port: Legion::Settings[:transport][:connection][:port])
25
+ )
26
+ @channel_thread = Concurrent::ThreadLocalVar.new(nil)
27
+ session.start
28
+ session.create_channel.basic_qos(1)
16
29
  else
17
30
  @session ||= Concurrent::Atom.new(
18
31
  connector.new(
19
32
  Legion::Settings[:transport][:connection],
20
- logger: Legion::Logging::Logger.new(level: 'warn'), log_level: :info
33
+ logger: Legion::Logging::Logger.new(level: 'warn'),
34
+ log_level: :info
21
35
  )
22
36
  )
23
- @channel_thread = Concurrent::ThreadLocalVar.new
37
+ @channel_thread = Concurrent::ThreadLocalVar.new(nil)
38
+ session.start
39
+ session.create_channel.basic_qos(20, true)
24
40
  end
25
41
 
26
- session.start
27
- session.create_channel.basic_qos(1, true)
42
+ if session.respond_to? :on_blocked
43
+ session.on_blocked { Legion::Logging.warn('Legion::Transport is being blocked by RabbitMQ!') }
44
+ end
45
+
46
+ if session.respond_to? :on_unblocked
47
+ session.on_unblocked { Legion::Logging.info('Legion::Transport is no longer being blocked by RabbitMQ') }
48
+ end
49
+
50
+ if session.respond_to? :after_recovery_completed
51
+ session.after_recovery_completed { Legion::Logging.info('Legion::Transport has completed recovery') }
52
+ end
53
+
54
+ true
28
55
  end
29
56
 
30
- def channel
57
+ def channel # rubocop:disable Metrics/AbcSize
31
58
  return @channel_thread.value if !@channel_thread.value.nil? && @channel_thread.value.open?
32
59
 
33
60
  @channel_thread.value = session.create_channel
34
- @channel_thread.value.prefetch(Legion::Settings[:transport][:prefetch])
61
+ if Legion::Transport::TYPE == 'march_hare'
62
+ @channel_thread.value.basic_qos(Legion::Settings[:transport][:prefetch])
63
+ else
64
+ @channel_thread.value.prefetch(Legion::Settings[:transport][:prefetch])
65
+ end
35
66
  @channel_thread.value
36
67
  end
37
68
 
@@ -3,6 +3,7 @@ module Legion
3
3
  class Consumer < Legion::Transport::CONNECTOR::Consumer
4
4
  include Legion::Transport::Common
5
5
  attr_reader :consumer_tag
6
+
6
7
  def initialize(queue:, no_ack: false, exclusive: false, consumer_tag: generate_consumer_tag, **opts)
7
8
  @consumer_tag = consumer_tag
8
9
  super(channel, queue, consumer_tag, no_ack, exclusive, opts)
@@ -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
@@ -39,7 +45,7 @@ module Legion
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
 
@@ -8,10 +8,12 @@ module Legion
8
8
  validate
9
9
  end
10
10
 
11
- def publish(options = @options)
11
+ def publish(options = @options) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
12
12
  raise unless @valid
13
13
 
14
- exchange_dest = exchange.respond_to?(:new) ? exchange.new : exchange
14
+ $exchanges = {} if $exchanges.nil?
15
+ $exchanges[exchange.to_s] = exchange.new unless $exchanges.key?(exchange.to_s)
16
+ exchange_dest = $exchanges[exchange.to_s]
15
17
  exchange_dest.publish(encode_message,
16
18
  routing_key: routing_key || '',
17
19
  content_type: options[:content_type] || content_type,
@@ -26,14 +28,24 @@ module Legion
26
28
  @options
27
29
  end
28
30
 
31
+ def routing_key
32
+ nil
33
+ end
34
+
29
35
  def encode_message
30
36
  message_payload = message
31
- message_payload = Legion::JSON.dump(message_payload) if message_payload.is_a? Hash
32
- @options[:content_encoding] = 'identity'
33
- return message_payload unless encrypt? && Legion::Settings[:crypt][:cs_encrypt_ready]
37
+ message_payload = Legion::JSON.dump(message_payload) unless message_payload.is_a? String
38
+
39
+ if encrypt?
40
+ encrypted = Legion::Crypt.encrypt(message_payload)
41
+ headers[:iv] = encrypted[:iv]
42
+ @options[:content_encoding] = 'encrypted/cs'
43
+ return encrypted[:enciphered_message]
44
+ else
45
+ @options[:content_encoding] = 'identity'
46
+ end
34
47
 
35
- @options[:content_encoding] = 'encrypted/cs'
36
- encrypt_message(message_payload)
48
+ message_payload
37
49
  end
38
50
 
39
51
  def encrypt_message(message, _type = 'cs')
@@ -41,7 +53,7 @@ module Legion
41
53
  end
42
54
 
43
55
  def encrypt?
44
- Legion::Settings[:transport][:messages][:encrypt]
56
+ Legion::Settings[:transport][:messages][:encrypt] && Legion::Settings[:crypt][:cs_encrypt_ready]
45
57
  end
46
58
 
47
59
  def exchange_name
@@ -97,4 +109,4 @@ module Legion
97
109
  end
98
110
  end
99
111
 
100
- Dir[__dir__ + '/messages/*.rb'].sort.each { |file| require file }
112
+ Dir["#{__dir__}/messages/*.rb"].sort.each { |file| require file }
@@ -1,6 +1,7 @@
1
- module Legion::Transport::Messages
1
+ module Legion::Transport::Messages # rubocop:disable Style/ClassAndModuleChildren
2
2
  class Dynamic < Legion::Transport::Message
3
3
  attr_accessor :options
4
+
4
5
  def type
5
6
  'task'
6
7
  end
@@ -1,4 +1,4 @@
1
- module Legion::Transport::Messages
1
+ module Legion::Transport::Messages # rubocop:disable Style/ClassAndModuleChildren
2
2
  class RequestClusterSecret < Legion::Transport::Message
3
3
  def routing_key
4
4
  'node.crypt.push_cluster_secret'
@@ -7,9 +7,10 @@ module Legion::Transport::Messages
7
7
  def message
8
8
  { function: 'push_cluster_secret',
9
9
  node_name: Legion::Settings[:client][:name],
10
- queue_name: "node.#{Legion::Settings['client']['name']}",
10
+ queue_name: "node.#{Legion::Settings[:client][:name]}",
11
11
  runner_class: 'Legion::Extensions::Node::Runners::Crypt',
12
- public_key: Base64.encode64(Legion::Crypt.public_key) }
12
+ # public_key: Base64.encode64(Legion::Crypt.public_key) }
13
+ public_key: Legion::Crypt.public_key }
13
14
  end
14
15
 
15
16
  def exchange
@@ -16,17 +16,6 @@ module Legion
16
16
  }
17
17
  end
18
18
 
19
- def routing_key
20
- if @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[:function_id].is_a? Integer
25
- function = Legion::Data::Model::Function[@options[:function_id]]
26
- "#{function.runner.extension.values[:exchange]}.#{function.runner.values[:queue]}.#{function.values[:name]}"
27
- end
28
- end
29
-
30
19
  def validate
31
20
  raise TypeError unless @options[:function].is_a? String
32
21
 
@@ -23,8 +23,7 @@ module Legion
23
23
  conditioner = ['conditioner.queued', 'conditioner.failed', 'conditioner.exception']
24
24
  transformer = ['transformer.queued', 'transformer.succeeded', 'transformer.exception']
25
25
  task = ['task.scheduled', 'task.queued', 'task.completed', 'task.exception', 'task.delayed']
26
- status = conditioner + transformer + task
27
- status
26
+ conditioner + transformer + task
28
27
  end
29
28
  end
30
29
  end
@@ -7,7 +7,7 @@ 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
12
  recreate_queue(channel, queue)
13
13
  retry
@@ -26,9 +26,11 @@ module Legion
26
26
  hash[:exclusive] = false
27
27
  hash[:block] = false
28
28
  hash[:auto_delete] = false
29
- hash[:arguments] = { 'x-max-priority': 255,
30
- 'x-overflow': 'reject-publish',
31
- 'x-dead-letter-exchange': "#{self.class.ancestors.first.to_s.split('::')[2].downcase}.dlx" }
29
+ hash[:arguments] = {
30
+ 'x-max-priority': 255,
31
+ 'x-overflow': 'reject-publish',
32
+ 'x-dead-letter-exchange': "#{self.class.ancestors.first.to_s.split('::')[2].downcase}.dlx"
33
+ }
32
34
  hash
33
35
  end
34
36
 
@@ -49,7 +51,7 @@ module Legion
49
51
  def delete(options = { if_unused: true, if_empty: true })
50
52
  super(options)
51
53
  true
52
- rescue ::Bunny::PreconditionFailed
54
+ rescue Legion::Transport::CONNECTOR::PreconditionFailed
53
55
  false
54
56
  end
55
57
 
@@ -57,7 +59,7 @@ module Legion
57
59
  channel.acknowledge(delivery_tag)
58
60
  end
59
61
 
60
- def reject(delivery_tag, requeue = false)
62
+ def reject(delivery_tag, requeue: false)
61
63
  channel.reject(delivery_tag, requeue)
62
64
  end
63
65
  end
@@ -0,0 +1,21 @@
1
+ module Legion
2
+ module Transport
3
+ module Queues
4
+ class NodeCrypt < Legion::Transport::Queue
5
+ def queue_name
6
+ 'node.status'
7
+ end
8
+
9
+ def queue_options
10
+ hash = {}
11
+ hash[:manual_ack] = true
12
+ hash[:durable] = true
13
+ hash[:exclusive] = false
14
+ hash[:block] = false
15
+ hash[:arguments] = { 'x-dead-letter-exchange': 'node.dlx' }
16
+ hash
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,5 @@
1
+ require 'legion/settings'
2
+
1
3
  module Legion
2
4
  module Transport
3
5
  module Settings
@@ -21,8 +23,10 @@ module Legion
21
23
  end
22
24
 
23
25
  def self.grab_vault_creds
24
- {} unless Legion::Settings[:vault][:connected]
25
- lease = Legion::Crypt.read('rabbitmq/creds/legion')
26
+ return {} unless Legion::Settings[:crypt][:vault][:connected]
27
+
28
+ lease = Legion::Crypt.read('rabbitmq/creds/legion', type: nil)
29
+ Legion::Logging.debug 'successfully grabbed amqp username from Vault'
26
30
  { user: lease[:username], password: lease[:password] }
27
31
  rescue StandardError
28
32
  {}
@@ -61,4 +65,8 @@ module Legion
61
65
  end
62
66
  end
63
67
 
64
- Legion::Settings.merge_settings('transport', Legion::Transport::Settings.default) if Legion.const_defined?('Settings')
68
+ begin
69
+ Legion::Settings.merge_settings('transport', Legion::Transport::Settings.default) if Legion.const_defined?('Settings')
70
+ rescue StandardError => e
71
+ Legion::Logging.fatal(e.message) if Legion::Logging.method_defined?(:fatal)
72
+ end
@@ -1,5 +1,5 @@
1
1
  module Legion
2
2
  module Transport
3
- VERSION = '1.0.0'.freeze
3
+ VERSION = '1.1.4'.freeze
4
4
  end
5
5
  end
@@ -1,9 +1,5 @@
1
- {"transport": {
2
- "rabbitmq": {
3
- "host": "localhost",
4
- "vhost": "legion",
5
- "user": "guest",
6
- "password": "guest"
1
+ {
2
+ "transport": {
3
+ "vhost": "legion"
7
4
  }
8
5
  }
9
- }
@@ -0,0 +1,12 @@
1
+ sonar.projectKey=legion-io_legion-transport
2
+ sonar.organization=legion-io
3
+ sonar.projectName=Legion::Transport
4
+ sonar.sources=.
5
+ sonar.exclusions=vendor/**
6
+ sonar.coverage.exclusions=spec/**
7
+ sonar.ruby.coverage.reportPath=coverage/.resultset.json
8
+ sonar.ruby.file.suffixes=rb,ruby
9
+ sonar.ruby.coverage.framework=RSpec
10
+ sonar.ruby.rubocopConfig=.rubocop.yml
11
+ sonar.ruby.rubocop.reportPath=rubocop-result.json
12
+ sonar.ruby.rubocop.filePath=.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legion-transport
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity
8
- autorequire:
9
- bindir: exe
8
+ autorequire:
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-12 00:00:00.000000000 Z
11
+ date: 2020-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -39,35 +39,35 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: legion-logging
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rspec
56
+ name: legion-settings
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '3.0'
61
+ version: '0'
62
62
  type: :development
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: '3.0'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rspec_junit_formatter
70
+ name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rubocop
84
+ name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: simplecov
98
+ name: rspec_junit_formatter
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,13 +109,13 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: concurrent-ruby
112
+ name: rubocop
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
- type: :runtime
118
+ type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
@@ -123,13 +123,13 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: concurrent-ruby-ext
126
+ name: simplecov
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
- type: :runtime
132
+ type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
@@ -137,13 +137,13 @@ dependencies:
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
- name: legion-settings
140
+ name: bunny
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
- type: :development
146
+ type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
@@ -151,7 +151,7 @@ dependencies:
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
- name: bunny
154
+ name: concurrent-ruby
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
@@ -165,13 +165,13 @@ dependencies:
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
- name: legion-logging
168
+ name: legion-json
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - ">="
172
172
  - !ruby/object:Gem::Version
173
173
  version: '0'
174
- type: :development
174
+ type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
@@ -187,12 +187,6 @@ extra_rdoc_files: []
187
187
  files:
188
188
  - ".circleci/config.yml"
189
189
  - ".gitignore"
190
- - ".idea/.rakeTasks"
191
- - ".idea/legion-transport.iml"
192
- - ".idea/misc.xml"
193
- - ".idea/modules.xml"
194
- - ".idea/vagrant.xml"
195
- - ".idea/workspace.xml"
196
190
  - ".rspec"
197
191
  - ".rubocop.yml"
198
192
  - CHANGELOG.md
@@ -223,12 +217,14 @@ files:
223
217
  - lib/legion/transport/messages/task_update.rb
224
218
  - lib/legion/transport/queue.rb
225
219
  - lib/legion/transport/queues/node.rb
220
+ - lib/legion/transport/queues/node_crypt.rb
226
221
  - lib/legion/transport/queues/node_status.rb
227
222
  - lib/legion/transport/queues/task_log.rb
228
223
  - lib/legion/transport/queues/task_update.rb
229
224
  - lib/legion/transport/settings.rb
230
225
  - lib/legion/transport/version.rb
231
226
  - settings/transport.json
227
+ - sonar-project.properties
232
228
  homepage: https://bitbucket.org/legion-io/legion-transport
233
229
  licenses: []
234
230
  metadata:
@@ -236,7 +232,7 @@ metadata:
236
232
  changelog_uri: https://bitbucket.org/legion-io/legion-transport/src/master/CHANGELOG.md
237
233
  homepage_uri: https://bitbucket.org/legion-io/legion-transport
238
234
  wiki_uri: https://bitbucket.org/legion-io/legion-transport/wiki/Home
239
- post_install_message:
235
+ post_install_message:
240
236
  rdoc_options: []
241
237
  require_paths:
242
238
  - lib
@@ -244,15 +240,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
244
240
  requirements:
245
241
  - - ">="
246
242
  - !ruby/object:Gem::Version
247
- version: '0'
243
+ version: 2.5.0
248
244
  required_rubygems_version: !ruby/object:Gem::Requirement
249
245
  requirements:
250
246
  - - ">="
251
247
  - !ruby/object:Gem::Version
252
248
  version: '0'
253
249
  requirements: []
254
- rubygems_version: 3.0.8
255
- signing_key:
250
+ rubygems_version: 3.1.2
251
+ signing_key:
256
252
  specification_version: 4
257
253
  summary: Used by Legion to connect with RabbitMQ
258
254
  test_files: []
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <Settings><!--This file was automatically generated by Ruby plugin.
3
- You are allowed to:
4
- 1. Remove rake task
5
- 2. Add existing rake tasks
6
- To add existing rake tasks automatically delete this file and reload the project.
7
- --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build legion-transport-0.1.1.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Build and install legion-transport-0.1.1.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install legion-transport-0.1.1.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeTask description="Create tag v0.1.1 and build and push legion-transport-0.1.1.gem to rubygems.org" fullCmd="release[remote]" taksId="release[remote]" /><RakeTask description="Run RSpec code examples" fullCmd="spec" taksId="spec" /><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="release" taksId="release" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>
@@ -1,45 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="RUBY_MODULE" version="4">
3
- <component name="ModuleRunConfigurationManager">
4
- <shared />
5
- </component>
6
- <component name="NewModuleRootManager">
7
- <content url="file://$MODULE_DIR$">
8
- <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
9
- </content>
10
- <orderEntry type="inheritedJdk" />
11
- <orderEntry type="sourceFolder" forTests="false" />
12
- <orderEntry type="library" scope="PROVIDED" name="amq-protocol (v2.3.0, RVM: ruby-2.6.3) [gem]" level="application" />
13
- <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.0, RVM: ruby-2.6.3) [gem]" level="application" />
14
- <orderEntry type="library" scope="PROVIDED" name="bundler (v2.1.4, RVM: ruby-2.6.3) [gem]" level="application" />
15
- <orderEntry type="library" scope="PROVIDED" name="bunny (v2.14.4, RVM: ruby-2.6.3) [gem]" level="application" />
16
- <orderEntry type="library" scope="PROVIDED" name="codecov (v0.1.16, RVM: ruby-2.6.3) [gem]" level="application" />
17
- <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.6, RVM: ruby-2.6.3) [gem]" level="application" />
18
- <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby-ext (v1.1.6, RVM: ruby-2.6.3) [gem]" level="application" />
19
- <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.3, RVM: ruby-2.6.3) [gem]" level="application" />
20
- <orderEntry type="library" scope="PROVIDED" name="docile (v1.3.2, RVM: ruby-2.6.3) [gem]" level="application" />
21
- <orderEntry type="library" scope="PROVIDED" name="jaro_winkler (v1.5.4, RVM: ruby-2.6.3) [gem]" level="application" />
22
- <orderEntry type="library" scope="PROVIDED" name="json (v2.3.0, RVM: ruby-2.6.3) [gem]" level="application" />
23
- <orderEntry type="library" scope="PROVIDED" name="legion-json (v0.1.6, RVM: ruby-2.6.3) [gem]" level="application" />
24
- <orderEntry type="library" scope="PROVIDED" name="legion-logging (v1.0.0, RVM: ruby-2.6.3) [gem]" level="application" />
25
- <orderEntry type="library" scope="PROVIDED" name="legion-settings (v1.0.0, RVM: ruby-2.6.3) [gem]" level="application" />
26
- <orderEntry type="library" scope="PROVIDED" name="oj (v3.10.5, RVM: ruby-2.6.3) [gem]" level="application" />
27
- <orderEntry type="library" scope="PROVIDED" name="parallel (v1.19.1, RVM: ruby-2.6.3) [gem]" level="application" />
28
- <orderEntry type="library" scope="PROVIDED" name="parser (v2.7.0.4, RVM: ruby-2.6.3) [gem]" level="application" />
29
- <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.0.0, RVM: ruby-2.6.3) [gem]" level="application" />
30
- <orderEntry type="library" scope="PROVIDED" name="rake (v10.5.0, RVM: ruby-2.6.3) [gem]" level="application" />
31
- <orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.4, RVM: ruby-2.6.3) [gem]" level="application" />
32
- <orderEntry type="library" scope="PROVIDED" name="rspec (v3.9.0, RVM: ruby-2.6.3) [gem]" level="application" />
33
- <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.9.1, RVM: ruby-2.6.3) [gem]" level="application" />
34
- <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.9.0, RVM: ruby-2.6.3) [gem]" level="application" />
35
- <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.9.1, RVM: ruby-2.6.3) [gem]" level="application" />
36
- <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.9.2, RVM: ruby-2.6.3) [gem]" level="application" />
37
- <orderEntry type="library" scope="PROVIDED" name="rspec_junit_formatter (v0.4.1, RVM: ruby-2.6.3) [gem]" level="application" />
38
- <orderEntry type="library" scope="PROVIDED" name="rubocop (v0.80.1, RVM: ruby-2.6.3) [gem]" level="application" />
39
- <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.10.1, RVM: ruby-2.6.3) [gem]" level="application" />
40
- <orderEntry type="library" scope="PROVIDED" name="simplecov (v0.18.5, RVM: ruby-2.6.3) [gem]" level="application" />
41
- <orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.12.2, RVM: ruby-2.6.3) [gem]" level="application" />
42
- <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v1.6.1, RVM: ruby-2.6.3) [gem]" level="application" />
43
- <orderEntry type="library" scope="PROVIDED" name="url (v0.3.2, RVM: ruby-2.6.3) [gem]" level="application" />
44
- </component>
45
- </module>
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="JavaScriptSettings">
4
- <option name="languageLevel" value="ES6" />
5
- </component>
6
- <component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-2.6.3" project-jdk-type="RUBY_SDK" />
7
- </project>
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/legion-transport.iml" filepath="$PROJECT_DIR$/.idea/legion-transport.iml" />
6
- </modules>
7
- </component>
8
- </project>
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VagrantProjectSettings">
4
- <option name="instanceFolder" value="" />
5
- <option name="provider" value="" />
6
- </component>
7
- </project>
@@ -1,14 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="CoverageOptionsProvider">
4
- <option name="myAddOrReplace" value="0" />
5
- </component>
6
- <component name="Git.Settings">
7
- <option name="PUSH_AUTO_UPDATE" value="true" />
8
- <option name="ROOT_SYNC" value="DONT_SYNC" />
9
- </component>
10
- <component name="ProjectId" id="1Yl3FmIkCYycmcT2pLSMAlN1Wxa" />
11
- <component name="PropertiesComponent">
12
- <property name="settings.editor.selected.configurable" value="reference.settingsdialog.project.vagrant" />
13
- </component>
14
- </project>