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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6deb308e07a5e4dd5751b18b80a9ea8b2052fcdac5fb9ece44c66a78b1090941
4
- data.tar.gz: 4b08ab911485e1d0e99d77b4b59a525b6596753e255c94510219f48ec6232442
3
+ metadata.gz: f588654525d1fc0d6e1d5e8324d6fc307530421151c8d90585fc59bc66fe1d04
4
+ data.tar.gz: 7415825fb5a440d3023f9cd5190b29a76bd6fd1007d00b7f1524c398ccbed668
5
5
  SHA512:
6
- metadata.gz: c67ad9fb03736e5917c42ca1fa25e3cd43636c16e6e4af28329d2a3bc347d69c7f21df68f654984c31837478eaffdf7bbe60b4c25a752809ba177dc3e0095190
7
- data.tar.gz: 6eabcd920c9d07fce081544889b39e07c9384810900ad78184ffacbaeb0df874e3d9c8087ec7910a380f9858ced0a1e07fb3eeadf897c8ad2b4271f78bf04ce5
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) && Legion::Settings[:transport][:connected]
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Legion
4
4
  module Transport
5
- VERSION = '1.4.8'
5
+ VERSION = '1.4.9'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legion-transport
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.8
4
+ version: 1.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity