legion-transport 1.3.14 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/lib/legion/transport/connection.rb +2 -1
- data/lib/legion/transport/exchange.rb +28 -0
- data/lib/legion/transport/message.rb +9 -2
- data/lib/legion/transport/settings.rb +3 -3
- data/lib/legion/transport/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a6f0e9a986dae9f69992c0d6c32eb296bbf5fe9bc1c66c746da0ef4eb782f722
|
|
4
|
+
data.tar.gz: 65d53aebe82cbaba12f6d660d91f1c819235b74663fce117d0405e1e8e780f2b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 812300aa2df2fea7cfbd7ded068acbac5b44a8487fa83e6df1a680b33e488a51f8db6fa4aeff34aa9fe2829060a71d05572ce209e6211788e113f6e1f41f8d98
|
|
7
|
+
data.tar.gz: 2ef6853180a0d22dd383f7cdec7e1f2875fe90b4d94cda2fd01c8b1991237de564c4fa5223fb01e6486ef7f2c2da688dea5f7aefa42ca94aa22ef973dc8522b1
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Legion::Transport ChangeLog
|
|
2
2
|
|
|
3
|
+
## [Unreleased]
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- Fix exchange instance cache inheritance: subclasses now correctly read from parent's @instance_cache, preventing boot crash
|
|
7
|
+
- Fix Connection#session: add missing `return` so nil check works correctly
|
|
8
|
+
- Message#publish: use `cached_instance` when available to reuse the exchange instance cache instead of always calling `.new`
|
|
9
|
+
- Message#publish: rescue `Timeout::Error` alongside other network errors so timeouts also spool
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- Bump read_timeout from 1 to 3 seconds
|
|
13
|
+
- Bump continuation_timeout from 4000 to 8000 milliseconds
|
|
14
|
+
- Bump session_worker_pool_size from 8 to 16
|
|
15
|
+
|
|
3
16
|
## [1.3.14] - 2026-03-24
|
|
4
17
|
|
|
5
18
|
### Fixed
|
|
@@ -5,11 +5,39 @@ module Legion
|
|
|
5
5
|
class Exchange < Legion::Transport::CONNECTOR::Exchange
|
|
6
6
|
include Legion::Transport::Common
|
|
7
7
|
|
|
8
|
+
# Thread-local cache of declared exchange instances keyed by class name.
|
|
9
|
+
# Avoids redundant exchange_declare calls on every publish.
|
|
10
|
+
@instance_cache = Concurrent::ThreadLocalVar.new { {} }
|
|
11
|
+
|
|
12
|
+
class << self
|
|
13
|
+
def instance_cache
|
|
14
|
+
Legion::Transport::Exchange.instance_variable_get(:@instance_cache)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def cached_instance
|
|
18
|
+
cache = instance_cache.value
|
|
19
|
+
inst = cache[name]
|
|
20
|
+
return inst if inst&.channel&.open?
|
|
21
|
+
|
|
22
|
+
cache.delete(name)
|
|
23
|
+
nil
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def cache_instance(inst)
|
|
27
|
+
instance_cache.value[name] = inst
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def clear_cache
|
|
31
|
+
instance_cache.value.clear
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
8
35
|
def initialize(exchange = exchange_name, options = {})
|
|
9
36
|
@options = options
|
|
10
37
|
@explicit_channel = @options.delete(:channel)
|
|
11
38
|
@type = options[:type] || default_type
|
|
12
39
|
super(channel, @type, exchange, options_builder(default_options, exchange_options, @options))
|
|
40
|
+
self.class.cache_instance(self) if self.class.respond_to?(:cache_instance)
|
|
13
41
|
rescue Legion::Transport::CONNECTOR::PreconditionFailed, Legion::Transport::CONNECTOR::ChannelAlreadyClosed
|
|
14
42
|
raise unless @retries.nil?
|
|
15
43
|
|
|
@@ -13,7 +13,14 @@ module Legion
|
|
|
13
13
|
def publish(options = @options)
|
|
14
14
|
raise unless @valid
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
ex_class = exchange
|
|
17
|
+
exchange_dest = if ex_class.respond_to?(:cached_instance)
|
|
18
|
+
ex_class.cached_instance || ex_class.new
|
|
19
|
+
elsif ex_class.respond_to?(:new)
|
|
20
|
+
ex_class.new
|
|
21
|
+
else
|
|
22
|
+
ex_class
|
|
23
|
+
end
|
|
17
24
|
exchange_dest.publish(encode_message,
|
|
18
25
|
routing_key: routing_key || '',
|
|
19
26
|
content_type: options[:content_type] || content_type,
|
|
@@ -30,7 +37,7 @@ module Legion
|
|
|
30
37
|
ex_name = exchange_dest.respond_to?(:name) ? exchange_dest.name : exchange_dest.to_s
|
|
31
38
|
Legion::Logging.debug "Published to exchange=#{ex_name} routing_key=#{routing_key || ''} class=#{self.class.name}" if defined?(Legion::Logging)
|
|
32
39
|
rescue Bunny::ConnectionClosedError, Bunny::ChannelAlreadyClosed, Bunny::ChannelError,
|
|
33
|
-
Bunny::NetworkErrorWrapper, IOError => e
|
|
40
|
+
Bunny::NetworkErrorWrapper, IOError, Timeout::Error => e
|
|
34
41
|
spool_message(e)
|
|
35
42
|
end
|
|
36
43
|
|
|
@@ -15,10 +15,10 @@ module Legion
|
|
|
15
15
|
extra_hosts = existing[:hosts] || []
|
|
16
16
|
|
|
17
17
|
{
|
|
18
|
-
read_timeout:
|
|
18
|
+
read_timeout: 3,
|
|
19
19
|
heartbeat: (ENV['transport.connection.heartbeat'] || 30).to_i,
|
|
20
20
|
automatically_recover: true,
|
|
21
|
-
continuation_timeout:
|
|
21
|
+
continuation_timeout: 8000,
|
|
22
22
|
network_recovery_interval: (ENV['transport.connection.recovery_interval'] || 2).to_i,
|
|
23
23
|
connection_timeout: (ENV['transport.connection.connection_timeout'] || 10).to_i,
|
|
24
24
|
frame_max: 65_536,
|
|
@@ -65,7 +65,7 @@ module Legion
|
|
|
65
65
|
def self.channel
|
|
66
66
|
{
|
|
67
67
|
default_worker_pool_size: ENV['transport.channel.default_worker_pool_size'] || 1,
|
|
68
|
-
session_worker_pool_size: ENV['transport.channel.session_worker_pool_size'] ||
|
|
68
|
+
session_worker_pool_size: ENV['transport.channel.session_worker_pool_size'] || 16
|
|
69
69
|
}
|
|
70
70
|
end
|
|
71
71
|
|