legion-transport 1.1.5 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/bitbucket-pipelines.yml +2 -1
- data/lib/legion/transport/connection.rb +3 -1
- data/lib/legion/transport/exchange.rb +2 -2
- data/lib/legion/transport/message.rb +11 -7
- data/lib/legion/transport/messages/task.rb +41 -0
- data/lib/legion/transport/queue.rb +2 -2
- data/lib/legion/transport/settings.rb +3 -2
- data/lib/legion/transport/version.rb +1 -1
- data/settings/transport.json +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 567b542ea43b5a232f8abdde592f899666b9dff1e976fe6c14790394ab056bd2
|
4
|
+
data.tar.gz: 103aab3379485b1731119820f26b8b38b25fd8592efe9b1e6c7fa10aa9f629e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66958af49eba04baee630061c0359078cbf02955392b830e921587044425e7b3333d511198006d7324a49e4364a56ad98b2234a4b55b6724029b5c7f805c0676
|
7
|
+
data.tar.gz: ddeddc83b4a865af2a9ee817732f7102b8bde0ef5b8b729b8959dea1176ab9da945ce42b799a55e6bc5f83101f38a11756a0e519355b9fd296f1de6f353de4fa
|
data/.rubocop.yml
CHANGED
data/bitbucket-pipelines.yml
CHANGED
@@ -8,7 +8,7 @@ module Legion
|
|
8
8
|
Legion::Transport::CONNECTOR
|
9
9
|
end
|
10
10
|
|
11
|
-
def setup # rubocop:disable Metrics/AbcSize,Metrics/
|
11
|
+
def setup # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
12
12
|
Legion::Logging.info("Using transport connector: #{Legion::Transport::CONNECTOR}")
|
13
13
|
|
14
14
|
if @session.respond_to?(:value) && session.respond_to?(:closed?) && session.closed?
|
@@ -26,6 +26,7 @@ module Legion
|
|
26
26
|
@channel_thread = Concurrent::ThreadLocalVar.new(nil)
|
27
27
|
session.start
|
28
28
|
session.create_channel.basic_qos(1)
|
29
|
+
Legion::Settings[:transport][:connected] = true
|
29
30
|
else
|
30
31
|
@session ||= Concurrent::Atom.new(
|
31
32
|
connector.new(
|
@@ -37,6 +38,7 @@ module Legion
|
|
37
38
|
@channel_thread = Concurrent::ThreadLocalVar.new(nil)
|
38
39
|
session.start
|
39
40
|
session.create_channel.basic_qos(20, true)
|
41
|
+
Legion::Settings[:transport][:connected] = true
|
40
42
|
end
|
41
43
|
|
42
44
|
if session.respond_to? :on_blocked
|
@@ -27,7 +27,7 @@ module Legion
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def default_options
|
30
|
-
hash =
|
30
|
+
hash = Concurrent::Hash.new
|
31
31
|
hash[:durable] = true
|
32
32
|
hash[:auto_delete] = false
|
33
33
|
hash[:arguments] = {}
|
@@ -39,7 +39,7 @@ module Legion
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def exchange_options
|
42
|
-
|
42
|
+
Concurrent::Hash.new
|
43
43
|
end
|
44
44
|
|
45
45
|
def delete(options = {})
|
@@ -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,12 +22,20 @@ 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
|
|
29
37
|
def routing_key
|
30
|
-
|
38
|
+
@options[:routing_key] if @options.key? :routing_key
|
31
39
|
end
|
32
40
|
|
33
41
|
def encode_message
|
@@ -64,7 +72,7 @@ module Legion
|
|
64
72
|
end
|
65
73
|
|
66
74
|
def headers
|
67
|
-
@options[:headers] ||=
|
75
|
+
@options[:headers] ||= Concurrent::Hash.new
|
68
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
|
69
77
|
next unless @options.key? header
|
70
78
|
|
@@ -80,10 +88,6 @@ module Legion
|
|
80
88
|
0
|
81
89
|
end
|
82
90
|
|
83
|
-
def expiration
|
84
|
-
nil
|
85
|
-
end
|
86
|
-
|
87
91
|
def content_type
|
88
92
|
'application/json'
|
89
93
|
end
|
@@ -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
|
@@ -20,7 +20,7 @@ module Legion
|
|
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
|
data/settings/transport.json
CHANGED
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.1.
|
4
|
+
version: 1.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esity
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -191,6 +191,7 @@ files:
|
|
191
191
|
- ".rubocop.yml"
|
192
192
|
- CHANGELOG.md
|
193
193
|
- Gemfile
|
194
|
+
- Gemfile.lock
|
194
195
|
- README.md
|
195
196
|
- Rakefile
|
196
197
|
- bin/console
|
@@ -213,6 +214,7 @@ files:
|
|
213
214
|
- lib/legion/transport/messages/node_health.rb
|
214
215
|
- lib/legion/transport/messages/request_cluster_secret.rb
|
215
216
|
- lib/legion/transport/messages/subtask.rb
|
217
|
+
- lib/legion/transport/messages/task.rb
|
216
218
|
- lib/legion/transport/messages/task_log.rb
|
217
219
|
- lib/legion/transport/messages/task_update.rb
|
218
220
|
- lib/legion/transport/queue.rb
|