legion-transport 1.1.2 → 1.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +4 -18
- data/.rubocop.yml +7 -0
- data/CHANGELOG.md +13 -0
- data/bitbucket-pipelines.yml +12 -22
- data/legion-transport.gemspec +7 -12
- data/lib/legion/transport.rb +5 -6
- data/lib/legion/transport/connection.rb +57 -9
- data/lib/legion/transport/exchange.rb +11 -5
- data/lib/legion/transport/message.rb +19 -7
- data/lib/legion/transport/messages/dynamic.rb +2 -1
- data/lib/legion/transport/messages/task.rb +41 -0
- data/lib/legion/transport/messages/task_update.rb +7 -2
- data/lib/legion/transport/queue.rb +9 -9
- data/lib/legion/transport/settings.rb +4 -2
- data/lib/legion/transport/version.rb +1 -1
- metadata +26 -41
- data/bin/console +0 -14
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63d52e031c058a898022ffe052a75fdee6bd83208f37e5413e5e1b361883d3bd
|
4
|
+
data.tar.gz: 5be4a5d602de235d0ff73fab3f31c93f8ac664eee869f4e0bd6f36e3471dc49e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f65bf581a683147c76a1b64d410b1603397f1f66365209b2bae6d89607e967cac7aaf641b9a88dfb9e434ef5ac4871da9737ff2bf0814a52331730c0ff3f1145
|
7
|
+
data.tar.gz: ada8ca704e24de54ff6096b094b1352117495b7c1f9a3ce67bdbb107629dbd4b77282193b55b0f7f7617b6214f4943e44ad30d95b8d4feb1333bc23b2bba3d32
|
data/.circleci/config.yml
CHANGED
@@ -14,6 +14,7 @@ jobs:
|
|
14
14
|
- run:
|
15
15
|
name: Run Rubocop
|
16
16
|
command: bundle exec rubocop
|
17
|
+
- sonarcloud/scan
|
17
18
|
- ruby/save-cache
|
18
19
|
"ruby-two-five":
|
19
20
|
docker:
|
@@ -27,6 +28,7 @@ jobs:
|
|
27
28
|
command: gem update bundler
|
28
29
|
- ruby/install-deps
|
29
30
|
- ruby/run-tests
|
31
|
+
- sonarcloud/scan
|
30
32
|
- ruby/save-cache
|
31
33
|
"ruby-two-six":
|
32
34
|
docker:
|
@@ -40,6 +42,7 @@ jobs:
|
|
40
42
|
command: gem update bundler
|
41
43
|
- ruby/install-deps
|
42
44
|
- ruby/run-tests
|
45
|
+
- sonarcloud/scan
|
43
46
|
- ruby/save-cache
|
44
47
|
"ruby-two-seven":
|
45
48
|
docker:
|
@@ -53,19 +56,6 @@ jobs:
|
|
53
56
|
command: gem update bundler
|
54
57
|
- ruby/install-deps
|
55
58
|
- ruby/run-tests
|
56
|
-
- ruby/save-cache
|
57
|
-
"sonarcloud":
|
58
|
-
docker:
|
59
|
-
- image: circleci/ruby:2.7
|
60
|
-
- image: rabbitmq:3.7
|
61
|
-
steps:
|
62
|
-
- 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
|
69
59
|
- sonarcloud/scan
|
70
60
|
- ruby/save-cache
|
71
61
|
|
@@ -82,8 +72,4 @@ workflows:
|
|
82
72
|
- ruby-two-five
|
83
73
|
- ruby-two-seven:
|
84
74
|
requires:
|
85
|
-
- ruby-two-five
|
86
|
-
- sonarcloud:
|
87
|
-
requires:
|
88
|
-
- ruby-two-seven
|
89
|
-
- ruby-two-six
|
75
|
+
- ruby-two-five
|
data/.rubocop.yml
CHANGED
@@ -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:
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,17 @@
|
|
1
1
|
# Legion::Transport ChangeLog
|
2
2
|
|
3
|
+
## v1.1.8
|
4
|
+
* Removing codecov gem
|
5
|
+
* Changing bunny gem requirement to `>= 2.17.0`
|
6
|
+
* Changing current-ruby gem requirement to `>= 1.1.7`
|
7
|
+
* Removing JRuby support
|
8
|
+
* Removing bin/ folder
|
9
|
+
* Cleaning up some channel objects inside Messages and Queues
|
10
|
+
|
11
|
+
## v1.1.3
|
12
|
+
* Adding JRuby support via a different gem
|
13
|
+
* Adding more logic on choosing which gem to pick for the CONNECTOR
|
14
|
+
* Cleaning up some rubocop things
|
15
|
+
|
3
16
|
## v1.1.2
|
4
17
|
Updating queue auto_delete to be false
|
data/bitbucket-pipelines.yml
CHANGED
@@ -1,24 +1,14 @@
|
|
1
|
-
image: ruby:2.
|
1
|
+
image: ruby:2.7
|
2
2
|
|
3
3
|
pipelines:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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/**
|
data/legion-transport.gemspec
CHANGED
@@ -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 =
|
6
|
+
spec.name = 'legion-transport'
|
7
7
|
spec.version = Legion::Transport::VERSION
|
8
8
|
spec.authors = ['Esity']
|
9
9
|
spec.email = ['matthewdiverson@gmail.com']
|
@@ -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,23 +23,17 @@ 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.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
26
|
spec.require_paths = ['lib']
|
27
27
|
|
28
|
-
spec.add_development_dependency 'bundler'
|
29
|
-
spec.add_development_dependency 'codecov'
|
30
28
|
spec.add_development_dependency 'legion-logging'
|
31
29
|
spec.add_development_dependency 'legion-settings'
|
32
|
-
spec.add_development_dependency 'rake'
|
33
|
-
spec.add_development_dependency 'rspec'
|
30
|
+
spec.add_development_dependency 'rake'
|
31
|
+
spec.add_development_dependency 'rspec'
|
34
32
|
spec.add_development_dependency 'rspec_junit_formatter'
|
35
33
|
spec.add_development_dependency 'rubocop'
|
36
34
|
spec.add_development_dependency 'simplecov'
|
37
|
-
spec.add_dependency 'concurrent-ruby'
|
38
35
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
spec.add_dependency 'bunny'
|
43
|
-
end
|
36
|
+
spec.add_dependency 'bunny', '>= 2.17.0'
|
37
|
+
spec.add_dependency 'concurrent-ruby', '>= 1.1.7'
|
38
|
+
spec.add_dependency 'legion-json'
|
44
39
|
end
|
data/lib/legion/transport.rb
CHANGED
@@ -3,11 +3,11 @@ require_relative 'transport/settings'
|
|
3
3
|
|
4
4
|
module Legion
|
5
5
|
module Transport
|
6
|
-
|
7
|
-
require '
|
8
|
-
TYPE = '
|
9
|
-
CONNECTOR = ::
|
10
|
-
|
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,78 @@ module Legion
|
|
4
4
|
module Transport
|
5
5
|
module Connection
|
6
6
|
class << self
|
7
|
+
def new
|
8
|
+
clone
|
9
|
+
end
|
10
|
+
|
7
11
|
def connector
|
8
12
|
Legion::Transport::CONNECTOR
|
9
13
|
end
|
10
14
|
|
11
|
-
def
|
15
|
+
def reconnect(connection_name: 'Legion', **)
|
16
|
+
@session = nil
|
17
|
+
@channel_thread = Concurrent::ThreadLocalVar.new(nil)
|
18
|
+
setup(connection_name: connection_name)
|
19
|
+
end
|
20
|
+
|
21
|
+
def setup(connection_name: 'Legion', **) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
22
|
+
Legion::Logging.info("Using transport connector: #{Legion::Transport::CONNECTOR}")
|
23
|
+
|
12
24
|
if @session.respond_to?(:value) && session.respond_to?(:closed?) && session.closed?
|
13
|
-
@channel_thread = Concurrent::ThreadLocalVar.new
|
25
|
+
@channel_thread = Concurrent::ThreadLocalVar.new(nil)
|
14
26
|
elsif @session.respond_to?(:value) && session.respond_to?(:closed?) && session.open?
|
15
|
-
|
27
|
+
nil
|
28
|
+
elsif Legion::Transport::TYPE == 'march_hare'
|
29
|
+
@session ||= Concurrent::AtomicReference.new(
|
30
|
+
MarchHare.connect(host: Legion::Settings[:transport][:connection][:host],
|
31
|
+
vhost: Legion::Settings[:transport][:connection][:vhost],
|
32
|
+
user: Legion::Settings[:transport][:connection][:user],
|
33
|
+
password: Legion::Settings[:transport][:connection][:password],
|
34
|
+
port: Legion::Settings[:transport][:connection][:port])
|
35
|
+
)
|
36
|
+
@channel_thread = Concurrent::ThreadLocalVar.new(nil)
|
37
|
+
session.start
|
38
|
+
session.create_channel.basic_qos(1)
|
39
|
+
Legion::Settings[:transport][:connected] = true
|
16
40
|
else
|
17
|
-
@session ||= Concurrent::
|
41
|
+
@session ||= Concurrent::AtomicReference.new(
|
18
42
|
connector.new(
|
19
43
|
Legion::Settings[:transport][:connection],
|
44
|
+
connection_name: connection_name,
|
20
45
|
logger: Legion::Logging::Logger.new(level: 'warn'),
|
21
46
|
log_level: :info
|
22
47
|
)
|
23
48
|
)
|
24
|
-
@channel_thread = Concurrent::ThreadLocalVar.new
|
49
|
+
@channel_thread = Concurrent::ThreadLocalVar.new(nil)
|
50
|
+
session.start
|
51
|
+
session.create_channel.basic_qos(20, true)
|
52
|
+
Legion::Settings[:transport][:connected] = true
|
53
|
+
end
|
54
|
+
|
55
|
+
if session.respond_to? :on_blocked
|
56
|
+
session.on_blocked { Legion::Logging.warn('Legion::Transport is being blocked by RabbitMQ!') }
|
57
|
+
end
|
58
|
+
|
59
|
+
if session.respond_to? :on_unblocked
|
60
|
+
session.on_unblocked { Legion::Logging.info('Legion::Transport is no longer being blocked by RabbitMQ') }
|
25
61
|
end
|
26
62
|
|
27
|
-
session.
|
28
|
-
|
63
|
+
if session.respond_to? :after_recovery_completed
|
64
|
+
session.after_recovery_completed { Legion::Logging.info('Legion::Transport has completed recovery') }
|
65
|
+
end
|
66
|
+
|
67
|
+
true
|
29
68
|
end
|
30
69
|
|
31
|
-
def channel
|
70
|
+
def channel # rubocop:disable Metrics/AbcSize
|
32
71
|
return @channel_thread.value if !@channel_thread.value.nil? && @channel_thread.value.open?
|
33
72
|
|
34
73
|
@channel_thread.value = session.create_channel
|
35
|
-
|
74
|
+
if Legion::Transport::TYPE == 'march_hare'
|
75
|
+
@channel_thread.value.basic_qos(Legion::Settings[:transport][:prefetch])
|
76
|
+
else
|
77
|
+
@channel_thread.value.prefetch(Legion::Settings[:transport][:prefetch])
|
78
|
+
end
|
36
79
|
@channel_thread.value
|
37
80
|
end
|
38
81
|
|
@@ -47,14 +90,19 @@ module Legion
|
|
47
90
|
|
48
91
|
def channel_open?
|
49
92
|
channel.open?
|
93
|
+
rescue StandardError
|
94
|
+
false
|
50
95
|
end
|
51
96
|
|
52
97
|
def session_open?
|
53
98
|
session.open?
|
99
|
+
rescue StandardError
|
100
|
+
false
|
54
101
|
end
|
55
102
|
|
56
103
|
def shutdown
|
57
104
|
session.close
|
105
|
+
@session = nil
|
58
106
|
end
|
59
107
|
end
|
60
108
|
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
|
-
|
10
|
-
|
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,13 +39,13 @@ 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 ::
|
48
|
+
rescue Legion::Transport::CONNECTOR::PreconditionFailed
|
43
49
|
false
|
44
50
|
end
|
45
51
|
|
@@ -8,7 +8,7 @@ module Legion
|
|
8
8
|
validate
|
9
9
|
end
|
10
10
|
|
11
|
-
def publish(options = @options) # rubocop:disable Metrics/AbcSize
|
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,8 +107,12 @@ 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
|
105
117
|
|
106
|
-
Dir[__dir__
|
118
|
+
Dir["#{__dir__}/messages/*.rb"].sort.each { |file| require file }
|
@@ -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
|
6
|
-
|
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 ::
|
10
|
+
rescue Legion::Transport::CONNECTOR::PreconditionFailed
|
11
11
|
retries.zero? ? retries = 1 : raise
|
12
|
-
recreate_queue(
|
12
|
+
recreate_queue(queue)
|
13
13
|
retry
|
14
14
|
end
|
15
15
|
|
16
|
-
def recreate_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,10 +35,10 @@ module Legion
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def queue_options
|
38
|
-
|
38
|
+
Concurrent::Hash.new
|
39
39
|
end
|
40
40
|
|
41
|
-
def queue_name
|
41
|
+
def queue_name
|
42
42
|
ancestor = self.class.ancestors.first.to_s.split('::')
|
43
43
|
name = if ancestor[5].scan(/[A-Z]/).length > 1
|
44
44
|
ancestor[5].gsub!(/(.)([A-Z])/, '\1_\2').downcase!
|
@@ -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 ::
|
54
|
+
rescue Legion::Transport::CONNECTOR::PreconditionFailed
|
55
55
|
false
|
56
56
|
end
|
57
57
|
|
@@ -59,7 +59,7 @@ module Legion
|
|
59
59
|
channel.acknowledge(delivery_tag)
|
60
60
|
end
|
61
61
|
|
62
|
-
def reject(delivery_tag, requeue
|
62
|
+
def reject(delivery_tag, requeue: false)
|
63
63
|
channel.reject(delivery_tag, requeue)
|
64
64
|
end
|
65
65
|
end
|
@@ -7,18 +7,20 @@ module Legion
|
|
7
7
|
def self.connection
|
8
8
|
{
|
9
9
|
read_timeout: 1,
|
10
|
-
heartbeat:
|
10
|
+
heartbeat: 30,
|
11
11
|
automatically_recover: true,
|
12
12
|
continuation_timeout: 4000,
|
13
13
|
network_recovery_interval: 1,
|
14
14
|
connection_timeout: 1,
|
15
|
+
frame_max: 65_536,
|
15
16
|
user: 'guest',
|
16
17
|
password: 'guest',
|
17
18
|
host: '127.0.0.1',
|
18
19
|
port: '5672',
|
19
20
|
vhost: '/',
|
20
21
|
recovery_attempts: 0,
|
21
|
-
logger_level: 'info'
|
22
|
+
logger_level: 'info',
|
23
|
+
connected: false
|
22
24
|
}.merge(grab_vault_creds)
|
23
25
|
end
|
24
26
|
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: legion-transport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esity
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: legion-logging
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: legion-settings
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -67,35 +67,21 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '10.0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '10.0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rspec
|
70
|
+
name: rspec_junit_formatter
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
|
-
- - "
|
73
|
+
- - ">="
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
75
|
+
version: '0'
|
90
76
|
type: :development
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
|
-
- - "
|
80
|
+
- - ">="
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
82
|
+
version: '0'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
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:
|
98
|
+
name: simplecov
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
101
|
- - ">="
|
@@ -123,35 +109,35 @@ dependencies:
|
|
123
109
|
- !ruby/object:Gem::Version
|
124
110
|
version: '0'
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
112
|
+
name: bunny
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
128
114
|
requirements:
|
129
115
|
- - ">="
|
130
116
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
132
|
-
type: :
|
117
|
+
version: 2.17.0
|
118
|
+
type: :runtime
|
133
119
|
prerelease: false
|
134
120
|
version_requirements: !ruby/object:Gem::Requirement
|
135
121
|
requirements:
|
136
122
|
- - ">="
|
137
123
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
124
|
+
version: 2.17.0
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: concurrent-ruby
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
142
128
|
requirements:
|
143
129
|
- - ">="
|
144
130
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
131
|
+
version: 1.1.7
|
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:
|
138
|
+
version: 1.1.7
|
153
139
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
140
|
+
name: legion-json
|
155
141
|
requirement: !ruby/object:Gem::Requirement
|
156
142
|
requirements:
|
157
143
|
- - ">="
|
@@ -180,8 +166,6 @@ files:
|
|
180
166
|
- Gemfile.lock
|
181
167
|
- README.md
|
182
168
|
- Rakefile
|
183
|
-
- bin/console
|
184
|
-
- bin/setup
|
185
169
|
- bitbucket-pipelines.yml
|
186
170
|
- legion-transport.gemspec
|
187
171
|
- lib/legion/transport.rb
|
@@ -200,6 +184,7 @@ files:
|
|
200
184
|
- lib/legion/transport/messages/node_health.rb
|
201
185
|
- lib/legion/transport/messages/request_cluster_secret.rb
|
202
186
|
- lib/legion/transport/messages/subtask.rb
|
187
|
+
- lib/legion/transport/messages/task.rb
|
203
188
|
- lib/legion/transport/messages/task_log.rb
|
204
189
|
- lib/legion/transport/messages/task_update.rb
|
205
190
|
- lib/legion/transport/queue.rb
|
@@ -219,7 +204,7 @@ metadata:
|
|
219
204
|
changelog_uri: https://bitbucket.org/legion-io/legion-transport/src/master/CHANGELOG.md
|
220
205
|
homepage_uri: https://bitbucket.org/legion-io/legion-transport
|
221
206
|
wiki_uri: https://bitbucket.org/legion-io/legion-transport/wiki/Home
|
222
|
-
post_install_message:
|
207
|
+
post_install_message:
|
223
208
|
rdoc_options: []
|
224
209
|
require_paths:
|
225
210
|
- lib
|
@@ -227,15 +212,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
227
212
|
requirements:
|
228
213
|
- - ">="
|
229
214
|
- !ruby/object:Gem::Version
|
230
|
-
version:
|
215
|
+
version: 2.5.0
|
231
216
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
232
217
|
requirements:
|
233
218
|
- - ">="
|
234
219
|
- !ruby/object:Gem::Version
|
235
220
|
version: '0'
|
236
221
|
requirements: []
|
237
|
-
rubygems_version: 3.1.
|
238
|
-
signing_key:
|
222
|
+
rubygems_version: 3.1.4
|
223
|
+
signing_key:
|
239
224
|
specification_version: 4
|
240
225
|
summary: Used by Legion to connect with RabbitMQ
|
241
226
|
test_files: []
|
data/bin/console
DELETED
@@ -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__)
|