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: 7b23cd42819001403fdf176b48df36e0d0acd9fd65a625e24a65899ba3496715
4
- data.tar.gz: aa7316e0ef335e0cbc423ae5b9f201b6e076d971373966b60e2db229f9b86fc4
3
+ metadata.gz: cedfb5503324f13c9b7b9ecda3cecfaacec5d077c2fc339c9374d5195cd7b05f
4
+ data.tar.gz: 692e36d9effbec4c2dfd64b4447f1314768f1e76d9b8298eccfbfaa2f350f87d
5
5
  SHA512:
6
- metadata.gz: d45af1a0c4478d1310763cf3dd33effe6a96fdc6f76ab1dcbcf15fc710a7ad618d82515ec32d9ed65b4ac520c64d1c6722ba1614c57bf56b77823e003d45641a
7
- data.tar.gz: 3655fa57a8e56e9e31b8b2aa9c40abca15abe7ed7f35c512a31585992c4cbd985e2aef3884e429c76f6362ca4c83c517389089eb7c86084764abe9f121fe931c
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
- raise "Failed to update ECS task protection state: #{response.body}"
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
- rescue StandardError => e
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
@@ -3,7 +3,7 @@
3
3
  module PlatformSdk
4
4
  MAJOR = 3
5
5
  MINOR = 33
6
- PATCH = 0
6
+ PATCH = 1
7
7
 
8
8
  VERSION = "#{PlatformSdk::MAJOR}.#{PlatformSdk::MINOR}.#{PlatformSdk::PATCH}".freeze
9
9
  end
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.0
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-07-28 00:00:00.000000000 Z
11
+ date: 2026-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64