yes-command-api 2.6.0 → 2.7.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c4371d32c7707cab5fa15aa81b5ce049bfa4df1e76fd018b33b52487badf20b8
|
|
4
|
+
data.tar.gz: 9530367c5c71954dfb4050d5bbdae2cc54a579e4d314cfdbc69fcd12486e1b56
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 326e8d06be087f3ff857056922a3160d9348572a8e2995e086dc3a0a202ef68f5b99453ee91d72a9cad0e9d33d5bef031612a157a42a04beebba34a887cf508e
|
|
7
|
+
data.tar.gz: 3c5d4478eb4e9cd6dc5f944c47d8eb5060239b7737307e630c6cf94fb35975e99a818c7e9cf2fdff6a2377f9e349d9a93bfd61c70bc9517aa76695b376b1f93e
|
|
@@ -10,6 +10,7 @@ module Yes
|
|
|
10
10
|
# If no auth adapter is configured, authentication will raise an error.
|
|
11
11
|
class CommandsController < ActionController::API
|
|
12
12
|
MAX_INLINE_COMMANDS_PER_REQ = 10
|
|
13
|
+
RETRY_AFTER_SECONDS = 1
|
|
13
14
|
|
|
14
15
|
include Yes::Core::OpenTelemetry::Trackable
|
|
15
16
|
|
|
@@ -17,6 +18,12 @@ module Yes
|
|
|
17
18
|
before_action :set_channel
|
|
18
19
|
|
|
19
20
|
rescue_from(StandardError, with: :handle_unexpected_error)
|
|
21
|
+
# Declared after StandardError: Rails checks the last declared handler first.
|
|
22
|
+
rescue_from(
|
|
23
|
+
Cerbos::Error::Unavailable,
|
|
24
|
+
Cerbos::Error::DeadlineExceeded,
|
|
25
|
+
with: :authorization_service_unavailable_response
|
|
26
|
+
)
|
|
20
27
|
rescue_from(Yes::Core::AuthenticationError, with: :auth_error_response)
|
|
21
28
|
|
|
22
29
|
rescue_from(
|
|
@@ -189,6 +196,20 @@ module Yes
|
|
|
189
196
|
span_kind: :client
|
|
190
197
|
)
|
|
191
198
|
|
|
199
|
+
# Authorization of the whole batch precedes any execution, so nothing ran and the client
|
|
200
|
+
# can safely retry the request.
|
|
201
|
+
def authorization_service_unavailable_response(error)
|
|
202
|
+
self.class.current_span&.status = OpenTelemetry::Trace::Status.error(error.message)
|
|
203
|
+
self.class.current_span&.record_exception(error)
|
|
204
|
+
Rails.error.report(error, handled: true, severity: :error)
|
|
205
|
+
|
|
206
|
+
response.set_header('Retry-After', RETRY_AFTER_SECONDS.to_s)
|
|
207
|
+
render(
|
|
208
|
+
json: { title: 'Service Unavailable', detail: 'Authorization service unavailable' }.to_json,
|
|
209
|
+
status: :service_unavailable
|
|
210
|
+
)
|
|
211
|
+
end
|
|
212
|
+
|
|
192
213
|
def handle_unexpected_error(error)
|
|
193
214
|
self.class.current_span&.status = OpenTelemetry::Trace::Status.error(error.message)
|
|
194
215
|
self.class.current_span&.record_exception(error)
|