legion-transport 1.2.4 → 1.2.6
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 +17 -0
- data/CLAUDE.md +1 -1
- data/README.md +20 -1
- data/lib/legion/transport/connection/ssl.rb +1 -1
- data/lib/legion/transport/connection.rb +22 -6
- data/lib/legion/transport/settings.rb +28 -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: 988d986c0f2f13a18b7c3ddd5dfbb31c181f7dd6b5e4c5ca80f27cd866007a7b
|
|
4
|
+
data.tar.gz: 68fafccc5b87f5f7fdee59076da8080997f109f42bb09292c50fd0cffea7723c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8a617816dff976eb89ef9134b59f4a06857fc1150b2c9d286acc7f32730668c19d0a7dd90db25b7b7d723a86912119326e4f6736b1b971b23875931042d35234
|
|
7
|
+
data.tar.gz: 237efb345c04d8c79561b59b278b98528e92e7d344c1b06689fa8951928900acaf4e7f1cc52e65d728ce0209d72cf26c1cdf665c673600ad061e6f91eff858d1
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Legion::Transport ChangeLog
|
|
2
2
|
|
|
3
|
+
## [1.2.6] - 2026-03-20
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
- Version bump to trigger CI rebuild
|
|
7
|
+
|
|
8
|
+
## [1.2.5] - 2026-03-20
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- `Settings.resolve_hosts` — merges `host:`, `hosts:`, `server:`, `servers:` into a unified deduped list with default AMQP port (5672) injected where missing
|
|
12
|
+
- `Settings::DEFAULT_AMQP_PORT` constant (5672)
|
|
13
|
+
- Multi-host RabbitMQ cluster failover via Bunny's native `hosts:` parameter when 2+ hosts configured
|
|
14
|
+
- Support for `server:` and `servers:` keys in transport settings (consistency with legion-cache)
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- Port default changed from string `"5672"` to integer `5672` — fixes SSL auto-detect comparison in `Connection::SSL.use_tls?` which compared against integer `5671`
|
|
18
|
+
- SSL port auto-detect now uses `.to_i` for robustness
|
|
19
|
+
|
|
3
20
|
## [1.2.4] - 2026-03-20
|
|
4
21
|
|
|
5
22
|
### Fixed
|
data/CLAUDE.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
Ruby gem that manages the connection between LegionIO and its FIFO queue system (RabbitMQ over AMQP 0.9.1). Provides abstractions for exchanges, queues, messages, and consumers with thread-safe connection management.
|
|
9
9
|
|
|
10
10
|
**GitHub**: https://github.com/LegionIO/legion-transport
|
|
11
|
-
**Version**: 1.2.
|
|
11
|
+
**Version**: 1.2.5
|
|
12
12
|
**License**: Apache-2.0
|
|
13
13
|
|
|
14
14
|
## Architecture
|
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Legion::Transport is the Ruby gem responsible for connecting LegionIO to its FIFO queue system (RabbitMQ over AMQP 0.9.1). It provides thread-safe connection management, exchange/queue abstractions, message publishing with optional encryption, and consumer wrappers.
|
|
4
4
|
|
|
5
|
-
**Version**: 1.2.
|
|
5
|
+
**Version**: 1.2.5
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
@@ -71,6 +71,25 @@ exchange = Legion::Transport::Exchanges::Task.new
|
|
|
71
71
|
exchange.publish(payload, routing_key: 'task.my_runner.my_function')
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
+
## Connection Configuration
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"transport": {
|
|
79
|
+
"connection": {
|
|
80
|
+
"host": "rabbitmq1.example.com",
|
|
81
|
+
"servers": ["rabbitmq2.example.com", "rabbitmq3.example.com:5673"],
|
|
82
|
+
"port": 5672,
|
|
83
|
+
"user": "legion",
|
|
84
|
+
"password": "secret",
|
|
85
|
+
"vhost": "/"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Supported server keys: `host:` (string), `hosts:` (array), `server:` (string), `servers:` (array). All are merged and deduped. Port 5672 is injected where omitted. Multiple hosts enable Bunny's cluster failover.
|
|
92
|
+
|
|
74
93
|
## Configuration
|
|
75
94
|
|
|
76
95
|
Configuration is managed through `legion-settings` with environment variable overrides:
|
|
@@ -33,12 +33,7 @@ module Legion
|
|
|
33
33
|
nil
|
|
34
34
|
else
|
|
35
35
|
@session ||= Concurrent::AtomicReference.new(
|
|
36
|
-
connector.new(
|
|
37
|
-
Legion::Settings[:transport][:connection],
|
|
38
|
-
connection_name: connection_name,
|
|
39
|
-
logger: Legion::Transport.logger,
|
|
40
|
-
log_level: :warn
|
|
41
|
-
)
|
|
36
|
+
connector.new(build_bunny_opts(connection_name: connection_name))
|
|
42
37
|
)
|
|
43
38
|
@channel_thread = Concurrent::ThreadLocalVar.new(nil)
|
|
44
39
|
session.start
|
|
@@ -97,6 +92,27 @@ module Legion
|
|
|
97
92
|
session.close
|
|
98
93
|
@session = nil
|
|
99
94
|
end
|
|
95
|
+
|
|
96
|
+
private
|
|
97
|
+
|
|
98
|
+
def build_bunny_opts(connection_name:)
|
|
99
|
+
conn_settings = Legion::Settings[:transport][:connection].dup
|
|
100
|
+
resolved = conn_settings.delete(:resolved_hosts) || []
|
|
101
|
+
|
|
102
|
+
opts = conn_settings.merge(
|
|
103
|
+
connection_name: connection_name,
|
|
104
|
+
logger: Legion::Transport.logger,
|
|
105
|
+
log_level: :warn
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
if resolved.length > 1
|
|
109
|
+
opts[:hosts] = resolved.map { |h| { host: h.split(':').first, port: h.split(':').last.to_i } }
|
|
110
|
+
opts.delete(:host)
|
|
111
|
+
opts.delete(:port)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
opts
|
|
115
|
+
end
|
|
100
116
|
end
|
|
101
117
|
end
|
|
102
118
|
end
|
|
@@ -6,6 +6,14 @@ module Legion
|
|
|
6
6
|
module Transport
|
|
7
7
|
module Settings
|
|
8
8
|
def self.connection
|
|
9
|
+
host = ENV['transport.connection.host'] || '127.0.0.1'
|
|
10
|
+
port = (ENV['transport.connection.port'] || DEFAULT_AMQP_PORT).to_i
|
|
11
|
+
|
|
12
|
+
existing = defined?(Legion::Settings) ? (Legion::Settings[:transport][:connection] || {}) : {}
|
|
13
|
+
extra_server = existing[:server]
|
|
14
|
+
extra_servers = existing[:servers] || []
|
|
15
|
+
extra_hosts = existing[:hosts] || []
|
|
16
|
+
|
|
9
17
|
{
|
|
10
18
|
read_timeout: 1,
|
|
11
19
|
heartbeat: 30,
|
|
@@ -16,15 +24,32 @@ module Legion
|
|
|
16
24
|
frame_max: 65_536,
|
|
17
25
|
user: ENV['transport.connection.user'] || 'guest',
|
|
18
26
|
password: ENV['transport.connection.password'] || 'guest',
|
|
19
|
-
host:
|
|
20
|
-
port:
|
|
27
|
+
host: host,
|
|
28
|
+
port: port,
|
|
21
29
|
vhost: ENV['transport.connection.vhost'] || '/',
|
|
22
30
|
recovery_attempts: 100,
|
|
23
31
|
logger_level: ENV['transport.log_level'] || 'info',
|
|
24
|
-
connected: false
|
|
32
|
+
connected: false,
|
|
33
|
+
resolved_hosts: resolve_hosts(
|
|
34
|
+
host: host, hosts: Array(extra_hosts),
|
|
35
|
+
server: extra_server, servers: Array(extra_servers),
|
|
36
|
+
port: port
|
|
37
|
+
)
|
|
25
38
|
}.merge(grab_vault_creds)
|
|
26
39
|
end
|
|
27
40
|
|
|
41
|
+
DEFAULT_AMQP_PORT = 5672
|
|
42
|
+
|
|
43
|
+
def self.resolve_hosts(host: nil, hosts: [], server: nil, servers: [], port: nil)
|
|
44
|
+
port ||= DEFAULT_AMQP_PORT
|
|
45
|
+
|
|
46
|
+
all = Array(hosts) + Array(servers) + Array(host) + Array(server)
|
|
47
|
+
all = ["127.0.0.1:#{port}"] if all.empty?
|
|
48
|
+
|
|
49
|
+
all.map! { |s| s.to_s.include?(':') ? s.to_s : "#{s}:#{port}" }
|
|
50
|
+
all.uniq
|
|
51
|
+
end
|
|
52
|
+
|
|
28
53
|
def self.grab_vault_creds
|
|
29
54
|
return {} unless Legion::Settings[:crypt][:vault][:connected]
|
|
30
55
|
|