strongmind-platform-sdk 3.33.0 → 3.33.1
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: cedfb5503324f13c9b7b9ecda3cecfaacec5d077c2fc339c9374d5195cd7b05f
|
|
4
|
+
data.tar.gz: 692e36d9effbec4c2dfd64b4447f1314768f1e76d9b8298eccfbfaa2f350f87d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2df771039e71183cc9e907059e539a97eea33256e1736cb0b9d2c9297f5c3fd9d73463229af854c4f27e1f5fe6c19406a5e76591bd628275786e8b99887e0928
|
|
7
|
+
data.tar.gz: 60b398f8141aa17c1307fc060d072f4396efa1f353e6f7d5b92f254c96149e6270fc3e8ad87583b567364390e3931eeff8b827e9ee243a2653e8118fca4f9432
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'sidekiq'
|
|
2
4
|
|
|
3
5
|
module PlatformSdk
|
|
4
6
|
module Sidekiq
|
|
5
|
-
|
|
6
7
|
class EcsTaskProtectionMiddleware
|
|
7
8
|
ECS_AGENT_URI = ENV['ECS_AGENT_URI']
|
|
8
9
|
STATE_ENDPOINT = "#{ECS_AGENT_URI}/task-protection/v1/state"
|
|
10
|
+
MAX_RETRIES = 3
|
|
9
11
|
@@mutex = Mutex.new
|
|
10
12
|
@@active_jobs = 0
|
|
11
13
|
|
|
@@ -28,6 +30,8 @@ module PlatformSdk
|
|
|
28
30
|
private
|
|
29
31
|
|
|
30
32
|
def set_task_protection(state)
|
|
33
|
+
retries = 0
|
|
34
|
+
|
|
31
35
|
begin
|
|
32
36
|
uri = URI.parse(STATE_ENDPOINT)
|
|
33
37
|
request = Net::HTTP::Put.new(uri)
|
|
@@ -38,15 +42,35 @@ module PlatformSdk
|
|
|
38
42
|
http.request(request)
|
|
39
43
|
end
|
|
40
44
|
|
|
41
|
-
unless response.is_a?(Net::HTTPSuccess)
|
|
42
|
-
|
|
45
|
+
raise "Failed to update ECS task protection state: #{response.body}" unless response.is_a?(Net::HTTPSuccess)
|
|
46
|
+
rescue StandardError => e
|
|
47
|
+
retries += 1
|
|
48
|
+
|
|
49
|
+
# Retry with exponential backoff for throttling errors:
|
|
50
|
+
if retries <= MAX_RETRIES && throttling_error?(e)
|
|
51
|
+
sleep(2**retries * (1 + rand * 0.5))
|
|
52
|
+
retry
|
|
43
53
|
end
|
|
44
54
|
|
|
45
|
-
|
|
55
|
+
# For disable (state=false): log and swallow - job already completed successfully
|
|
56
|
+
unless state
|
|
57
|
+
warn_message = "Failed to disable ECS task protection (non-fatal): #{e.message}"
|
|
58
|
+
if defined?(Rails) && Rails.respond_to?(:logger)
|
|
59
|
+
Rails.logger.warn(warn_message)
|
|
60
|
+
else
|
|
61
|
+
warn(warn_message)
|
|
62
|
+
end
|
|
63
|
+
return
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# For enable (state=true): raise - we need protection enabled before running the job
|
|
46
67
|
raise "An error occurred: #{e.message}"
|
|
47
68
|
end
|
|
48
69
|
end
|
|
49
|
-
end
|
|
50
70
|
|
|
71
|
+
def throttling_error?(error)
|
|
72
|
+
error.message.include?('ThrottlingException') || error.message.include?('Rate exceeded')
|
|
73
|
+
end
|
|
74
|
+
end
|
|
51
75
|
end
|
|
52
|
-
end
|
|
76
|
+
end
|
data/lib/platform_sdk/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: strongmind-platform-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.33.
|
|
4
|
+
version: 3.33.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Platform Team
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-08-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|