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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff91b1e257e5a3be9580e01bb3517deab0f5f912f031e081469034643e7b1f7a
4
- data.tar.gz: f940e2c6821e2015fb29e7d32746d53deaf36ad2fdc8c238c0ee519852b0710c
3
+ metadata.gz: 567b542ea43b5a232f8abdde592f899666b9dff1e976fe6c14790394ab056bd2
4
+ data.tar.gz: 103aab3379485b1731119820f26b8b38b25fd8592efe9b1e6c7fa10aa9f629e9
5
5
  SHA512:
6
- metadata.gz: 379c26d17de282b5342a4300197658ce222a822c2bbe10cffc4f459b7bb13689fe1b145e60237c9579bef58005e37ee60d85c9f18e23292791bfdbddb608604b
7
- data.tar.gz: d25558b9a4e10049ba187b4174bebf0e198e1914f08422db97ae79090a67e1150b8b9e5f1b795f55030bf3e2a4a0386ae10b67c1c9a19cddcf83fc67ddc6bba3
6
+ metadata.gz: 66958af49eba04baee630061c0359078cbf02955392b830e921587044425e7b3333d511198006d7324a49e4364a56ad98b2234a4b55b6724029b5c7f805c0676
7
+ data.tar.gz: ddeddc83b4a865af2a9ee817732f7102b8bde0ef5b8b729b8959dea1176ab9da945ce42b799a55e6bc5f83101f38a11756a0e519355b9fd296f1de6f353de4fa
@@ -6,6 +6,10 @@ Metrics/ClassLength:
6
6
  Max: 1500
7
7
  Metrics/BlockLength:
8
8
  Max: 50
9
+ Metrics/PerceivedComplexity:
10
+ Max: 15
11
+ Metrics/CyclomaticComplexity:
12
+ Max: 15
9
13
  Layout/SpaceAroundEqualsInParameterDefault:
10
14
  EnforcedStyle: space
11
15
  Style/SymbolArray:
@@ -1,4 +1,4 @@
1
- image: ruby:2.5.0
1
+ image: ruby:2.7.0
2
2
 
3
3
  pipelines:
4
4
  branches:
@@ -8,6 +8,7 @@ pipelines:
8
8
  - bundler
9
9
  script:
10
10
  - gem install bundle rubocop
11
+ - gem update bundler
11
12
  - bundle install
12
13
  - rubocop
13
14
  - rake
@@ -8,7 +8,7 @@ module Legion
8
8
  Legion::Transport::CONNECTOR
9
9
  end
10
10
 
11
- def setup # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
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,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,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
- nil
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
@@ -16,9 +16,10 @@ module Legion
16
16
  password: 'guest',
17
17
  host: '127.0.0.1',
18
18
  port: '5672',
19
- vhost: 'legion',
19
+ vhost: '/',
20
20
  recovery_attempts: 0,
21
- logger_level: 'info'
21
+ logger_level: 'info',
22
+ connected: false
22
23
  }.merge(grab_vault_creds)
23
24
  end
24
25
 
@@ -1,5 +1,5 @@
1
1
  module Legion
2
2
  module Transport
3
- VERSION = '1.1.5'.freeze
3
+ VERSION = '1.1.6'.freeze
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "transport": {
3
- "vhost": "legion"
3
+ "vhost": "/"
4
4
  }
5
5
  }
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.5
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-15 00:00:00.000000000 Z
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