strongmind-platform-sdk 3.19.37 → 3.19.39
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/Gemfile +3 -3
- data/Gemfile.lock +11 -10
- data/lib/platform_sdk/canvas_api/client.rb +2 -2
- data/lib/platform_sdk/sidekiq/ecs_task_protection_middleware.rb +52 -0
- data/lib/platform_sdk/sidekiq.rb +20 -0
- data/lib/platform_sdk/version.rb +1 -1
- data/lib/platform_sdk.rb +2 -0
- metadata +32 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c66fa25807f8ef3dc617523c236691009327152fb4b76245c38a22b921bd3a6
|
4
|
+
data.tar.gz: f70482e271a58d856217d767d591ff876fdb37d0e445402ac3be72766e0ba665
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5b3d8024a2712b1f109d11342a81c260304f85e0a8261c6708b31d74b39c77d4ed03a604809c87ec5dce7381c7ff38440d970b43126f5a7748f815542368a04
|
7
|
+
data.tar.gz: 20ec372d4ae073f31fb177bd405f13b3f34baa6167774658738654eb8866503c047e5f32e012fe9efd0cba7dbdbf11da3e3267e8d7f55f2cafcab48026a74153
|
data/Gemfile
CHANGED
@@ -4,13 +4,11 @@ source "https://rubygems.org"
|
|
4
4
|
|
5
5
|
gem "strongmind-oneroster-client", "~> 2.0.3"
|
6
6
|
|
7
|
-
|
8
7
|
# Specify your gem's dependencies in platform_sdk-ruby-sdk.gemspec
|
9
8
|
gemspec
|
10
9
|
|
11
10
|
gem "faraday"
|
12
11
|
gem "faraday-retry"
|
13
|
-
gem "faraday-multipart"
|
14
12
|
gem "jwt", "~> 1.5", ">= 1.5.4"
|
15
13
|
gem "learnosity-sdk", "~> 0.2.2"
|
16
14
|
gem "multi_json"
|
@@ -29,5 +27,7 @@ group :development, :test do
|
|
29
27
|
gem 'timecop'
|
30
28
|
end
|
31
29
|
|
32
|
-
|
33
30
|
gem "pry", "~> 0.14.2"
|
31
|
+
gem "strongmind-sidekiq-cloudwatchmetrics"
|
32
|
+
gem "sidekiq"
|
33
|
+
gem "aws-sdk-cloudwatch"
|
data/Gemfile.lock
CHANGED
@@ -4,6 +4,7 @@ PATH
|
|
4
4
|
strongmind-platform-sdk (3.19.0)
|
5
5
|
activesupport (~> 7.1)
|
6
6
|
asset_sync
|
7
|
+
aws-sdk-cloudwatch
|
7
8
|
aws-sdk-secretsmanager (~> 1.66)
|
8
9
|
faraday (~> 2.5, >= 2.5.2)
|
9
10
|
faraday-retry
|
@@ -13,6 +14,7 @@ PATH
|
|
13
14
|
multi_json
|
14
15
|
rails (~> 7.1)
|
15
16
|
sentry-ruby
|
17
|
+
sidekiq
|
16
18
|
strongmind-oneroster-client (~> 2.0.1)
|
17
19
|
strongmind-sidekiq-cloudwatchmetrics
|
18
20
|
uri
|
@@ -103,11 +105,11 @@ GEM
|
|
103
105
|
unf
|
104
106
|
ast (2.4.2)
|
105
107
|
aws-eventstream (1.3.0)
|
106
|
-
aws-partitions (1.
|
108
|
+
aws-partitions (1.977.0)
|
107
109
|
aws-sdk-cloudwatch (1.100.0)
|
108
110
|
aws-sdk-core (~> 3, >= 3.205.0)
|
109
111
|
aws-sigv4 (~> 1.5)
|
110
|
-
aws-sdk-core (3.
|
112
|
+
aws-sdk-core (3.206.0)
|
111
113
|
aws-eventstream (~> 1, >= 1.3.0)
|
112
114
|
aws-partitions (~> 1, >= 1.651.0)
|
113
115
|
aws-sigv4 (~> 1.9)
|
@@ -115,7 +117,7 @@ GEM
|
|
115
117
|
aws-sdk-secretsmanager (1.105.0)
|
116
118
|
aws-sdk-core (~> 3, >= 3.205.0)
|
117
119
|
aws-sigv4 (~> 1.5)
|
118
|
-
aws-sigv4 (1.
|
120
|
+
aws-sigv4 (1.10.0)
|
119
121
|
aws-eventstream (~> 1, >= 1.0.2)
|
120
122
|
base64 (0.2.0)
|
121
123
|
bigdecimal (3.1.8)
|
@@ -141,8 +143,6 @@ GEM
|
|
141
143
|
faraday (2.10.0)
|
142
144
|
faraday-net_http (>= 2.0, < 3.2)
|
143
145
|
logger
|
144
|
-
faraday-multipart (1.0.4)
|
145
|
-
multipart-post (~> 2)
|
146
146
|
faraday-net_http (3.1.1)
|
147
147
|
net-http
|
148
148
|
faraday-retry (2.2.1)
|
@@ -150,7 +150,7 @@ GEM
|
|
150
150
|
ffi (1.17.0)
|
151
151
|
ffi (1.17.0-x86_64-darwin)
|
152
152
|
ffi (1.17.0-x86_64-linux-gnu)
|
153
|
-
fog-aws (3.
|
153
|
+
fog-aws (3.27.0)
|
154
154
|
base64 (~> 0.2.0)
|
155
155
|
fog-core (~> 2.1)
|
156
156
|
fog-json (~> 1.1)
|
@@ -200,7 +200,6 @@ GEM
|
|
200
200
|
mini_portile2 (2.8.7)
|
201
201
|
minitest (5.24.1)
|
202
202
|
multi_json (1.15.0)
|
203
|
-
multipart-post (2.4.1)
|
204
203
|
mutex_m (0.2.0)
|
205
204
|
net-http (0.4.1)
|
206
205
|
uri
|
@@ -332,7 +331,7 @@ GEM
|
|
332
331
|
strongmind-oneroster-client (2.0.3)
|
333
332
|
json (~> 2.1, >= 2.1.0)
|
334
333
|
typhoeus (~> 1.0, >= 1.0.1)
|
335
|
-
strongmind-sidekiq-cloudwatchmetrics (2.6.
|
334
|
+
strongmind-sidekiq-cloudwatchmetrics (2.6.5)
|
336
335
|
aws-sdk-cloudwatch (~> 1.6)
|
337
336
|
sidekiq (>= 5.0, < 8.0)
|
338
337
|
strscan (3.1.0)
|
@@ -347,7 +346,7 @@ GEM
|
|
347
346
|
concurrent-ruby (~> 1.0)
|
348
347
|
unf (0.2.0)
|
349
348
|
unicode-display_width (2.5.0)
|
350
|
-
uri (0.13.
|
349
|
+
uri (0.13.1)
|
351
350
|
webmock (3.23.1)
|
352
351
|
addressable (>= 2.8.0)
|
353
352
|
crack (>= 0.3.2)
|
@@ -365,10 +364,10 @@ PLATFORMS
|
|
365
364
|
|
366
365
|
DEPENDENCIES
|
367
366
|
activesupport (~> 7.1, >= 7.1.3.2)
|
367
|
+
aws-sdk-cloudwatch
|
368
368
|
factory_bot
|
369
369
|
faker
|
370
370
|
faraday
|
371
|
-
faraday-multipart
|
372
371
|
faraday-retry
|
373
372
|
jwt (~> 1.5, >= 1.5.4)
|
374
373
|
learnosity-sdk (~> 0.2.2)
|
@@ -379,9 +378,11 @@ DEPENDENCIES
|
|
379
378
|
rspec-rails (~> 6.1.0)
|
380
379
|
rubocop
|
381
380
|
sentry-ruby
|
381
|
+
sidekiq
|
382
382
|
sqlite3 (~> 1.4)
|
383
383
|
strongmind-oneroster-client (~> 2.0.3)
|
384
384
|
strongmind-platform-sdk!
|
385
|
+
strongmind-sidekiq-cloudwatchmetrics
|
385
386
|
timecop
|
386
387
|
webmock
|
387
388
|
|
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "faraday"
|
4
|
-
require "faraday/multipart"
|
5
|
-
|
6
4
|
|
7
5
|
module PlatformSdk
|
8
6
|
module CanvasApiWrapper
|
@@ -540,7 +538,9 @@ module PlatformSdk
|
|
540
538
|
end
|
541
539
|
|
542
540
|
class CanvasClientError < StandardError; end
|
541
|
+
|
543
542
|
class LockedModuleItemError < CanvasClientError; end
|
543
|
+
|
544
544
|
class MissingModuleItemError < CanvasClientError; end
|
545
545
|
end
|
546
546
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'sidekiq'
|
2
|
+
|
3
|
+
module PlatformSdk
|
4
|
+
module Sidekiq
|
5
|
+
|
6
|
+
class EcsTaskProtectionMiddleware
|
7
|
+
ECS_AGENT_URI = ENV['ECS_AGENT_URI']
|
8
|
+
STATE_ENDPOINT = "#{ECS_AGENT_URI}/task-protection/v1/state"
|
9
|
+
@@mutex = Mutex.new
|
10
|
+
@@active_jobs = 0
|
11
|
+
|
12
|
+
def call(_, _, _)
|
13
|
+
@@mutex.synchronize do
|
14
|
+
@@active_jobs += 1
|
15
|
+
set_task_protection(true) if @@active_jobs == 1
|
16
|
+
end
|
17
|
+
|
18
|
+
begin
|
19
|
+
yield
|
20
|
+
ensure
|
21
|
+
@@mutex.synchronize do
|
22
|
+
@@active_jobs -= 1
|
23
|
+
set_task_protection(false) if @@active_jobs == 0
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def set_task_protection(state)
|
31
|
+
begin
|
32
|
+
uri = URI.parse(STATE_ENDPOINT)
|
33
|
+
request = Net::HTTP::Put.new(uri)
|
34
|
+
request['Content-Type'] = 'application/json'
|
35
|
+
request.body = { 'ProtectionEnabled' => state }.to_json
|
36
|
+
|
37
|
+
response = Net::HTTP.start(uri.hostname, uri.port) do |http|
|
38
|
+
http.request(request)
|
39
|
+
end
|
40
|
+
|
41
|
+
unless response.is_a?(Net::HTTPSuccess)
|
42
|
+
raise "Failed to update ECS task protection state: #{response.body}"
|
43
|
+
end
|
44
|
+
|
45
|
+
rescue StandardError => e
|
46
|
+
raise "An error occurred: #{e.message}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'sidekiq'
|
2
|
+
require 'sidekiq/cloud_watch_metrics'
|
3
|
+
|
4
|
+
module PlatformSdk
|
5
|
+
module Sidekiq
|
6
|
+
|
7
|
+
def self.send_metrics_to_cloudwatch!
|
8
|
+
::Sidekiq::CloudWatchMetrics.enable!
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.configure_task_protection
|
12
|
+
::Sidekiq.configure_server do |config|
|
13
|
+
config.server_middleware do |chain|
|
14
|
+
chain.add EcsTaskProtectionMiddleware
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
data/lib/platform_sdk/version.rb
CHANGED
data/lib/platform_sdk.rb
CHANGED
@@ -21,6 +21,8 @@ require "platform_sdk/spec_support"
|
|
21
21
|
require "asset_sync"
|
22
22
|
require "fog-aws"
|
23
23
|
require "platform_sdk/asset_sync_initializer"
|
24
|
+
require "platform_sdk/sidekiq/ecs_task_protection_middleware"
|
25
|
+
require "platform_sdk/sidekiq"
|
24
26
|
|
25
27
|
module PlatformSdk
|
26
28
|
class Error < StandardError; 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.19.
|
4
|
+
version: 3.19.39
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Platform Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -142,6 +142,34 @@ dependencies:
|
|
142
142
|
- - ">="
|
143
143
|
- !ruby/object:Gem::Version
|
144
144
|
version: '0'
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: sidekiq
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
type: :runtime
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: aws-sdk-cloudwatch
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :runtime
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
145
173
|
- !ruby/object:Gem::Dependency
|
146
174
|
name: strongmind-sidekiq-cloudwatchmetrics
|
147
175
|
requirement: !ruby/object:Gem::Requirement
|
@@ -274,6 +302,8 @@ files:
|
|
274
302
|
- lib/platform_sdk/power_school/client.rb
|
275
303
|
- lib/platform_sdk/power_school/special_program.rb
|
276
304
|
- lib/platform_sdk/sentry.rb
|
305
|
+
- lib/platform_sdk/sidekiq.rb
|
306
|
+
- lib/platform_sdk/sidekiq/ecs_task_protection_middleware.rb
|
277
307
|
- lib/platform_sdk/spec_support.rb
|
278
308
|
- lib/platform_sdk/spec_support/shared_examples/data_pipelineable_examples.rb
|
279
309
|
- lib/platform_sdk/spec_support/shared_examples/one_roster_data_pipelineable_examples.rb
|