legion-transport 1.4.8 → 1.4.9
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 +9 -0
- data/lib/legion/transport/helper.rb +68 -1
- 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: f588654525d1fc0d6e1d5e8324d6fc307530421151c8d90585fc59bc66fe1d04
|
|
4
|
+
data.tar.gz: 7415825fb5a440d3023f9cd5190b29a76bd6fd1007d00b7f1524c398ccbed668
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 979583ba6460228ac38a950efd245e841d280a46d3d67b5e14e54d740057d3b0decca4033b67cbcdf5e75b575d71f92a697d105058d88656456723d2fba0fd26
|
|
7
|
+
data.tar.gz: 00330f5a5f8b80df0596f16b047d15ffe57781e0ea2819728a092786e2e532e969fcc7a7da646576e4d8e7c6dec72dd34b240b902986d98da5436811b06f192e
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Legion::Transport ChangeLog
|
|
2
2
|
|
|
3
|
+
## [Unreleased]
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- Layered TTL resolution in Helper (`transport_default_ttl` — LEX-overridable, reads Settings)
|
|
7
|
+
- `transport_session_open?` / `transport_channel_open?` / `transport_lite_mode?` — real connection status
|
|
8
|
+
- `transport_channel` — convenience accessor for the current thread's AMQP channel
|
|
9
|
+
- `transport_spool_count` — pending spooled message count for degraded-mode awareness
|
|
10
|
+
- `transport_publish` — convenience method to publish to default exchange with auto TTL and JSON encoding
|
|
11
|
+
|
|
3
12
|
## [1.4.8] - 2026-03-28
|
|
4
13
|
|
|
5
14
|
### Added
|
|
@@ -3,6 +3,19 @@
|
|
|
3
3
|
module Legion
|
|
4
4
|
module Transport
|
|
5
5
|
module Helper
|
|
6
|
+
# --- TTL Resolution ---
|
|
7
|
+
# Override in your LEX to set a custom default message TTL for the extension.
|
|
8
|
+
# Resolution chain: per-call :ttl option -> LEX override -> Settings -> nil (no expiration)
|
|
9
|
+
def transport_default_ttl
|
|
10
|
+
return nil unless defined?(Legion::Settings)
|
|
11
|
+
|
|
12
|
+
Legion::Settings.dig(:transport, :messages, :ttl)
|
|
13
|
+
rescue StandardError
|
|
14
|
+
nil
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# --- Namespace / Wiring ---
|
|
18
|
+
|
|
6
19
|
def transport_path
|
|
7
20
|
@transport_path ||= "#{full_path}/transport"
|
|
8
21
|
end
|
|
@@ -37,8 +50,62 @@ module Legion
|
|
|
37
50
|
@default_exchange = transport_class::Exchanges.const_get(lex_const, false)
|
|
38
51
|
end
|
|
39
52
|
|
|
53
|
+
# --- Status ---
|
|
54
|
+
|
|
40
55
|
def transport_connected?
|
|
41
|
-
defined?(Legion::Settings)
|
|
56
|
+
return false unless defined?(Legion::Settings)
|
|
57
|
+
|
|
58
|
+
!!Legion::Settings.dig(:transport, :connected)
|
|
59
|
+
rescue StandardError
|
|
60
|
+
false
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def transport_session_open?
|
|
64
|
+
Legion::Transport::Connection.session_open?
|
|
65
|
+
rescue StandardError
|
|
66
|
+
false
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def transport_channel_open?
|
|
70
|
+
Legion::Transport::Connection.channel_open?
|
|
71
|
+
rescue StandardError
|
|
72
|
+
false
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def transport_lite_mode?
|
|
76
|
+
Legion::Transport::Connection.lite_mode?
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# --- Resource Info ---
|
|
80
|
+
|
|
81
|
+
def transport_channel
|
|
82
|
+
Legion::Transport::Connection.channel
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def transport_spool_count
|
|
86
|
+
Legion::Transport::Spool.count
|
|
87
|
+
rescue StandardError
|
|
88
|
+
0
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# --- Publish Convenience ---
|
|
92
|
+
|
|
93
|
+
def transport_publish(routing_key:, payload: {}, **opts)
|
|
94
|
+
return false unless transport_connected?
|
|
95
|
+
|
|
96
|
+
if opts.key?(:ttl)
|
|
97
|
+
ttl = opts.delete(:ttl)
|
|
98
|
+
opts[:expiration] = ttl.to_s if ttl
|
|
99
|
+
elsif !opts.key?(:expiration)
|
|
100
|
+
ttl = transport_default_ttl
|
|
101
|
+
opts[:expiration] = ttl.to_s if ttl
|
|
102
|
+
end
|
|
103
|
+
encoded = payload.is_a?(String) ? payload : Legion::JSON.dump(payload)
|
|
104
|
+
exchange = default_exchange.cached_instance || default_exchange.new
|
|
105
|
+
exchange.publish(encoded, routing_key: routing_key, **opts)
|
|
106
|
+
true
|
|
107
|
+
rescue StandardError
|
|
108
|
+
false
|
|
42
109
|
end
|
|
43
110
|
end
|
|
44
111
|
end
|