atlas_rb 1.8.9 → 1.8.10
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/.version +1 -1
- data/Gemfile.lock +1 -1
- data/lib/atlas_rb/faraday_helper.rb +36 -0
- 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: 2a1ca62f7d0e0d49e63754618a22967d8a89a4496c05c894bbbff7f13903e94d
|
|
4
|
+
data.tar.gz: 5645596297711e7cc464645d249b91b4b62108eaf71978f9d07ffed9590043cd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: acd99d449e3dd94bb23cfdeabfc1190d2a074e5bfe07a2a4a8e54723fad47680f525d52e761f5ccee50ac1b464a39b889331e6468fe63bb9a0b06f8d17526262
|
|
7
|
+
data.tar.gz: c2d0db210a2a66cb41bc68baec3b6158916a86866c9a20182efc1bc2240f26e0c00357e340d08b4313312e239fabc9338bbca3f6face3c9d0576ef13d9f1f74d
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.8.
|
|
1
|
+
1.8.10
|
data/Gemfile.lock
CHANGED
|
@@ -36,9 +36,28 @@ module AtlasRb
|
|
|
36
36
|
# If neither a signing key nor `ATLAS_JWT` is configured there is no relay
|
|
37
37
|
# credential, so the transport raises {AtlasRb::ConfigurationError}.
|
|
38
38
|
#
|
|
39
|
+
# ## Instrumentation
|
|
40
|
+
#
|
|
41
|
+
# Every builder brackets its request in an `ActiveSupport::Notifications`
|
|
42
|
+
# event named **`request.atlas_rb`** (Faraday's `:instrumentation`
|
|
43
|
+
# middleware, wired as the *outermost* handler so a redirect hop — e.g. the
|
|
44
|
+
# `/resources/:noid` NOID resolver — folds into one event per logical call
|
|
45
|
+
# rather than being double-counted). The payload is the Faraday `env`, so a
|
|
46
|
+
# subscriber reads `payload.method` / `payload.url` and the event's duration.
|
|
47
|
+
# This lets a host count/time Atlas round-trips (an N+1-over-HTTP detector)
|
|
48
|
+
# without reaching into gem internals. It is guarded on
|
|
49
|
+
# `defined?(ActiveSupport::Notifications)`: Rails hosts get the events; the
|
|
50
|
+
# headless BYO-JWT path (no AS loaded) is unaffected. With no subscriber
|
|
51
|
+
# attached the emit degrades to a listener lookup + `yield`, so it is safe to
|
|
52
|
+
# leave in the stack permanently — opt-in lives entirely on the consumer side.
|
|
53
|
+
#
|
|
39
54
|
# The module is mixed in via `extend`, so its methods become class methods on
|
|
40
55
|
# the host (e.g. `AtlasRb::Work.connection({})`).
|
|
41
56
|
module FaradayHelper
|
|
57
|
+
# ActiveSupport::Notifications event name emitted per outbound Atlas request.
|
|
58
|
+
# A dedicated name (not Faraday's default `request.faraday`) so a host that
|
|
59
|
+
# also uses Faraday for other clients can subscribe to Atlas traffic alone.
|
|
60
|
+
INSTRUMENTATION_EVENT = "request.atlas_rb"
|
|
42
61
|
# Wire contract Atlas enforces for relay-signing assertions (see Atlas
|
|
43
62
|
# ApplicationController#verify_cerberus_assertion). iss/aud are fixed; the
|
|
44
63
|
# short TTL bounds replay (Atlas allows 30s leeway on exp).
|
|
@@ -83,6 +102,7 @@ module AtlasRb
|
|
|
83
102
|
params: params,
|
|
84
103
|
headers: headers
|
|
85
104
|
) do |f|
|
|
105
|
+
instrument(f)
|
|
86
106
|
f.use AtlasRb::Middleware::RaiseOnStaleResource
|
|
87
107
|
f.use AtlasRb::Middleware::RaiseOnResourceError
|
|
88
108
|
f.response :follow_redirects
|
|
@@ -123,6 +143,7 @@ module AtlasRb
|
|
|
123
143
|
url: ENV.fetch("ATLAS_URL", nil),
|
|
124
144
|
headers: headers
|
|
125
145
|
) do |f|
|
|
146
|
+
instrument(f)
|
|
126
147
|
f.use AtlasRb::Middleware::RaiseOnStaleResource
|
|
127
148
|
# Translate Atlas's verify-on-ingest 422 (fixity_mismatch /
|
|
128
149
|
# unsupported_digest_algorithm) into a typed FixityMismatchError —
|
|
@@ -190,6 +211,7 @@ module AtlasRb
|
|
|
190
211
|
params: params,
|
|
191
212
|
headers: headers
|
|
192
213
|
) do |f|
|
|
214
|
+
instrument(f)
|
|
193
215
|
f.response :follow_redirects
|
|
194
216
|
f.adapter Faraday.default_adapter
|
|
195
217
|
end
|
|
@@ -197,6 +219,20 @@ module AtlasRb
|
|
|
197
219
|
|
|
198
220
|
private
|
|
199
221
|
|
|
222
|
+
# Register Faraday's instrumentation middleware as the OUTERMOST handler so
|
|
223
|
+
# each logical call emits exactly one {INSTRUMENTATION_EVENT} — a redirect
|
|
224
|
+
# hop (e.g. the `/resources/:noid` resolver) is bracketed with the request
|
|
225
|
+
# it redirects to, not counted twice. Guarded on
|
|
226
|
+
# `defined?(ActiveSupport::Notifications)` because Faraday defaults its
|
|
227
|
+
# instrumenter to that constant and would `NameError` at build time on the
|
|
228
|
+
# headless path where ActiveSupport isn't loaded; there, the emit is simply
|
|
229
|
+
# never wired and the transport is unaffected.
|
|
230
|
+
def instrument(builder)
|
|
231
|
+
return unless defined?(ActiveSupport::Notifications)
|
|
232
|
+
|
|
233
|
+
builder.request :instrumentation, name: INSTRUMENTATION_EVENT
|
|
234
|
+
end
|
|
235
|
+
|
|
200
236
|
# Build the auth + identity headers shared by {#connection} and {#multipart}.
|
|
201
237
|
# Precedence: ATLAS_JWT (BYO-JWT) > relay-signing. The acting nuid /
|
|
202
238
|
# on_behalf_of fall through to the configured `default_nuid` /
|