sidekiq-ecs-scaler 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e788a43a1d4013b88babd60929d35dc465dca7dbe73daa633566929be57f501
4
- data.tar.gz: 9a6c856115de94d05edb69662d2de03ea0ae536d40d3b36a1f74f1f2f2c9239b
3
+ metadata.gz: 61e35b0bdbfd171583e88d98453ff54f2715f4e8b59be4564a40f8f38e015b38
4
+ data.tar.gz: 9f36a75e28df3bb96a25f874d1d071853c9896732445ff5890129775855ebc32
5
5
  SHA512:
6
- metadata.gz: 137a41c9d0c6fbc53bb16652b7d9c711347618e2c3ce37130ce1087ec774c09956c0746e345d6bbd7bca5395aaa36b02c1f1a6a08e9a4c65a3eb51dd347a0280
7
- data.tar.gz: bdab45f712315863eb32d08e3aba9edb35db1d9d50f2966206baf6948ea1ce97cc9a6672402ffd09cd66ab27d5a222a02fa3fb8d902d9d7e9287bfb4045824e1
6
+ metadata.gz: 766e8fe9659709dea552de8cb0251f26cb14a0741b07e85fed48b6efd5cee3cced89cf018f76e96ddbe2f266f5c283f232e4cbeeab7b2832a9e530495b582f64
7
+ data.tar.gz: bfe755f5c853c03ba32e8e36af3ac9bc241dddcd2e5e636734c08a2560c00dc6926a9b7a494766c491009088d24ec387821e3a22bb5e7dbe65f3a49a81ae92df
data/.rubocop.yml CHANGED
@@ -1,3 +1,9 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rake
4
+ - rubocop-rspec
5
+ - rubocop-thread_safety
6
+
1
7
  AllCops:
2
8
  TargetRubyVersion: 2.6
3
9
  NewCops: enable
@@ -18,4 +24,8 @@ Metrics/BlockLength:
18
24
  - spec/**/*_spec.rb
19
25
 
20
26
  Naming/FileName:
27
+ Exclude:
28
+ - lib/sidekiq-ecs-scaler.rb
29
+
30
+ RSpec/MultipleMemoizedHelpers:
21
31
  Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## [0.3.0] - 2024-01-03
2
+
3
+ - Abolish non-thread safe configuration.
4
+ - Changed the mechanism to implement workers on the user side.
5
+
6
+ ## [0.2.0] - 2021-12-01
7
+
8
+ - Add configuration items
9
+ - `enabled` is possible to enable / disable the scale.
10
+ - `logger` is possible to changing the logger that outputs the required number of changes.
11
+ - UPDATE README.md
12
+
1
13
  ## [0.1.0] - 2021-11-29
2
14
 
3
15
  - initial release
data/Dockerfile CHANGED
@@ -1,14 +1,9 @@
1
- FROM ruby:3.0.3-slim
1
+ FROM ruby:3.2.2
2
2
 
3
- RUN apt-get update \
4
- && apt-get install -y build-essential git \
5
- && apt-get clean \
6
- && rm -rf /var/lib/apt/lists/*
3
+ WORKDIR /usr/src/gem
7
4
 
8
- WORKDIR /usr/src/sidekiq-ecs-scaler
9
-
10
- RUN mkdir -p lib/sidekiq-ecs-scaler \
11
- && echo "module SidekiqEcsScaler\n VERSION = \"0.1.0\"\nend\n" > lib/sidekiq-ecs-scaler/version.rb
5
+ RUN mkdir -p lib/sidekiq_ecs_scaler \
6
+ && echo "module SidekiqEcsScaler\n VERSION = \"0.1.0\"\nend\n" > lib/sidekiq_ecs_scaler/version.rb
12
7
 
13
8
  COPY bin/setup ./bin/
14
9
  COPY Gemfile Gemfile.lock sidekiq-ecs-scaler.gemspec .
data/Gemfile CHANGED
@@ -5,11 +5,13 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in sidekiq-ecs-scaler.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake"
9
- gem "rspec"
10
- gem "rubocop"
11
- gem "rubocop-rake"
12
- gem "rubocop-rspec"
13
- gem "simplecov"
14
- gem "steep"
15
- gem "yard"
8
+ gem "rake", require: false
9
+ gem "rspec", require: false
10
+ gem "rubocop", require: false
11
+ gem "rubocop-performance", require: false
12
+ gem "rubocop-rake", require: false
13
+ gem "rubocop-rspec", require: false
14
+ gem "rubocop-thread_safety", require: false
15
+ gem "simplecov", require: false
16
+ gem "steep", require: false
17
+ gem "yard", require: false
data/Gemfile.lock CHANGED
@@ -1,115 +1,157 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sidekiq-ecs-scaler (0.1.0)
4
+ sidekiq-ecs-scaler (0.3.0)
5
5
  aws-sdk-ecs (> 1, < 2)
6
- sidekiq (> 5, < 7)
6
+ sidekiq (> 5, < 8)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activesupport (6.1.4.1)
11
+ abbrev (0.1.2)
12
+ activesupport (7.1.2)
13
+ base64
14
+ bigdecimal
12
15
  concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ connection_pool (>= 2.2.5)
17
+ drb
13
18
  i18n (>= 1.6, < 2)
14
19
  minitest (>= 5.1)
20
+ mutex_m
15
21
  tzinfo (~> 2.0)
16
- zeitwerk (~> 2.3)
17
22
  ast (2.4.2)
18
- aws-eventstream (1.2.0)
19
- aws-partitions (1.535.0)
20
- aws-sdk-core (3.123.0)
21
- aws-eventstream (~> 1, >= 1.0.2)
22
- aws-partitions (~> 1, >= 1.525.0)
23
- aws-sigv4 (~> 1.1)
24
- jmespath (~> 1.0)
25
- aws-sdk-ecs (1.91.0)
26
- aws-sdk-core (~> 3, >= 3.122.0)
23
+ aws-eventstream (1.3.0)
24
+ aws-partitions (1.876.0)
25
+ aws-sdk-core (3.190.1)
26
+ aws-eventstream (~> 1, >= 1.3.0)
27
+ aws-partitions (~> 1, >= 1.651.0)
28
+ aws-sigv4 (~> 1.8)
29
+ jmespath (~> 1, >= 1.6.1)
30
+ aws-sdk-ecs (1.135.0)
31
+ aws-sdk-core (~> 3, >= 3.188.0)
27
32
  aws-sigv4 (~> 1.1)
28
- aws-sigv4 (1.4.0)
33
+ aws-sigv4 (1.8.0)
29
34
  aws-eventstream (~> 1, >= 1.0.2)
30
- concurrent-ruby (1.1.9)
31
- connection_pool (2.2.5)
32
- diff-lcs (1.4.4)
35
+ base64 (0.2.0)
36
+ bigdecimal (3.1.5)
37
+ concurrent-ruby (1.2.2)
38
+ connection_pool (2.4.1)
39
+ csv (3.2.8)
40
+ diff-lcs (1.5.0)
33
41
  docile (1.4.0)
34
- ffi (1.15.4)
35
- i18n (1.8.11)
42
+ drb (2.2.0)
43
+ ruby2_keywords
44
+ ffi (1.16.3)
45
+ fileutils (1.7.2)
46
+ i18n (1.14.1)
36
47
  concurrent-ruby (~> 1.0)
37
- jmespath (1.4.0)
38
- language_server-protocol (3.16.0.3)
39
- listen (3.7.0)
48
+ jmespath (1.6.2)
49
+ json (2.7.1)
50
+ language_server-protocol (3.17.0.3)
51
+ listen (3.8.0)
40
52
  rb-fsevent (~> 0.10, >= 0.10.3)
41
53
  rb-inotify (~> 0.9, >= 0.9.10)
42
- minitest (5.14.4)
43
- parallel (1.21.0)
44
- parser (3.0.3.0)
54
+ logger (1.6.0)
55
+ minitest (5.20.0)
56
+ mutex_m (0.2.0)
57
+ parallel (1.24.0)
58
+ parser (3.2.2.4)
45
59
  ast (~> 2.4.1)
46
- rack (2.2.3)
47
- rainbow (3.0.0)
48
- rake (13.0.6)
49
- rb-fsevent (0.11.0)
60
+ racc
61
+ racc (1.7.3)
62
+ rack (3.0.8)
63
+ rainbow (3.1.1)
64
+ rake (13.1.0)
65
+ rb-fsevent (0.11.2)
50
66
  rb-inotify (0.10.1)
51
67
  ffi (~> 1.0)
52
- rbs (1.7.1)
53
- redis (4.5.1)
54
- regexp_parser (2.1.1)
55
- rexml (3.2.5)
56
- rspec (3.10.0)
57
- rspec-core (~> 3.10.0)
58
- rspec-expectations (~> 3.10.0)
59
- rspec-mocks (~> 3.10.0)
60
- rspec-core (3.10.1)
61
- rspec-support (~> 3.10.0)
62
- rspec-expectations (3.10.1)
68
+ rbs (3.4.1)
69
+ abbrev
70
+ redis-client (0.19.1)
71
+ connection_pool
72
+ regexp_parser (2.8.3)
73
+ rexml (3.2.6)
74
+ rspec (3.12.0)
75
+ rspec-core (~> 3.12.0)
76
+ rspec-expectations (~> 3.12.0)
77
+ rspec-mocks (~> 3.12.0)
78
+ rspec-core (3.12.2)
79
+ rspec-support (~> 3.12.0)
80
+ rspec-expectations (3.12.3)
63
81
  diff-lcs (>= 1.2.0, < 2.0)
64
- rspec-support (~> 3.10.0)
65
- rspec-mocks (3.10.2)
82
+ rspec-support (~> 3.12.0)
83
+ rspec-mocks (3.12.6)
66
84
  diff-lcs (>= 1.2.0, < 2.0)
67
- rspec-support (~> 3.10.0)
68
- rspec-support (3.10.3)
69
- rubocop (1.23.0)
85
+ rspec-support (~> 3.12.0)
86
+ rspec-support (3.12.1)
87
+ rubocop (1.59.0)
88
+ json (~> 2.3)
89
+ language_server-protocol (>= 3.17.0)
70
90
  parallel (~> 1.10)
71
- parser (>= 3.0.0.0)
91
+ parser (>= 3.2.2.4)
72
92
  rainbow (>= 2.2.2, < 4.0)
73
93
  regexp_parser (>= 1.8, < 3.0)
74
- rexml
75
- rubocop-ast (>= 1.12.0, < 2.0)
94
+ rexml (>= 3.2.5, < 4.0)
95
+ rubocop-ast (>= 1.30.0, < 2.0)
76
96
  ruby-progressbar (~> 1.7)
77
- unicode-display_width (>= 1.4.0, < 3.0)
78
- rubocop-ast (1.13.0)
79
- parser (>= 3.0.1.1)
97
+ unicode-display_width (>= 2.4.0, < 3.0)
98
+ rubocop-ast (1.30.0)
99
+ parser (>= 3.2.1.0)
100
+ rubocop-capybara (2.19.0)
101
+ rubocop (~> 1.41)
102
+ rubocop-factory_bot (2.24.0)
103
+ rubocop (~> 1.33)
104
+ rubocop-performance (1.20.1)
105
+ rubocop (>= 1.48.1, < 2.0)
106
+ rubocop-ast (>= 1.30.0, < 2.0)
80
107
  rubocop-rake (0.6.0)
81
108
  rubocop (~> 1.0)
82
- rubocop-rspec (2.6.0)
83
- rubocop (~> 1.19)
84
- ruby-progressbar (1.11.0)
85
- sidekiq (6.3.1)
86
- connection_pool (>= 2.2.2)
87
- rack (~> 2.0)
88
- redis (>= 4.2.0)
89
- simplecov (0.21.2)
109
+ rubocop-rspec (2.25.0)
110
+ rubocop (~> 1.40)
111
+ rubocop-capybara (~> 2.17)
112
+ rubocop-factory_bot (~> 2.22)
113
+ rubocop-thread_safety (0.5.1)
114
+ rubocop (>= 0.90.0)
115
+ ruby-progressbar (1.13.0)
116
+ ruby2_keywords (0.0.5)
117
+ securerandom (0.3.1)
118
+ sidekiq (7.2.0)
119
+ concurrent-ruby (< 2)
120
+ connection_pool (>= 2.3.0)
121
+ rack (>= 2.2.4)
122
+ redis-client (>= 0.14.0)
123
+ simplecov (0.22.0)
90
124
  docile (~> 1.1)
91
125
  simplecov-html (~> 0.11)
92
126
  simplecov_json_formatter (~> 0.1)
93
127
  simplecov-html (0.12.3)
94
- simplecov_json_formatter (0.1.3)
95
- steep (0.46.0)
128
+ simplecov_json_formatter (0.1.4)
129
+ steep (1.6.0)
96
130
  activesupport (>= 5.1)
131
+ concurrent-ruby (>= 1.1.10)
132
+ csv (>= 3.0.9)
133
+ fileutils (>= 1.1.0)
134
+ json (>= 2.1.0)
97
135
  language_server-protocol (>= 3.15, < 4.0)
98
136
  listen (~> 3.0)
99
- parallel (>= 1.0.0)
100
- parser (>= 3.0)
137
+ logger (>= 1.3.0)
138
+ parser (>= 3.1)
101
139
  rainbow (>= 2.2.2, < 4.0)
102
- rbs (>= 1.2.0)
140
+ rbs (>= 3.1.0)
141
+ securerandom (>= 0.1)
142
+ strscan (>= 1.0.0)
103
143
  terminal-table (>= 2, < 4)
144
+ strscan (3.0.7)
104
145
  terminal-table (3.0.2)
105
146
  unicode-display_width (>= 1.1.1, < 3)
106
- tzinfo (2.0.4)
147
+ tzinfo (2.0.6)
107
148
  concurrent-ruby (~> 1.0)
108
- unicode-display_width (2.1.0)
109
- yard (0.9.26)
110
- zeitwerk (2.5.1)
149
+ unicode-display_width (2.5.0)
150
+ yard (0.9.34)
111
151
 
112
152
  PLATFORMS
153
+ aarch64-linux
154
+ arm64-darwin-21
113
155
  x86_64-darwin-19
114
156
  x86_64-linux
115
157
 
@@ -117,12 +159,14 @@ DEPENDENCIES
117
159
  rake
118
160
  rspec
119
161
  rubocop
162
+ rubocop-performance
120
163
  rubocop-rake
121
164
  rubocop-rspec
165
+ rubocop-thread_safety
122
166
  sidekiq-ecs-scaler!
123
167
  simplecov
124
168
  steep
125
169
  yard
126
170
 
127
171
  BUNDLED WITH
128
- 2.2.32
172
+ 2.4.10
data/README.md CHANGED
@@ -18,28 +18,33 @@ And then execute:
18
18
 
19
19
  ## Usage
20
20
 
21
- ### Configuration
21
+ ### Create Worker Class
22
22
 
23
23
  ```ruby
24
- SidekiqEcsScaler.configure do |config|
25
- # queue to monitor latency, default is "default"
26
- config.queue_name = "default"
24
+ # frozen_string_literal: true
27
25
 
28
- # minimum number of tasks, default is 1
29
- config.min_count = 1
26
+ class SidekiqEcsScaleWorker
27
+ include Sidekiq::Worker
30
28
 
31
- # maximum number of tasks, default is 1
32
- config.max_count = 3
33
-
34
- # maximum latency(seconds), default is 3600
35
- config.max_latency = 3600
29
+ # @return [void]
30
+ def perform
31
+ SidekiqEcsScaler::Client.update_desired_count(
32
+ max_count: 3
33
+ )
34
+ end
35
+ end
36
+ ```
36
37
 
37
- # custom ECS Client
38
- config.ecs_client = Aws::ECS::Client.new
38
+ Options
39
39
 
40
- # Set worker options for scaling
41
- config.sidekiq_options = { "retry" => true, "queue" => "scheduler" }
42
- end
40
+ ```yaml
41
+ logger: logger, default is Sidekiq.logger
42
+ queue_name: queue to monitor latency, default is "default"
43
+ min_count: minimum number of tasks, default is 1
44
+ max_count: maximum number of tasks, default is 1
45
+ step_count: steps number in the desired count range, default is 1
46
+ max_latency: maximum latency(seconds), default is 3600
47
+ ecs_client: custom ECS Client, default is Aws::ECS::Client.new
43
48
  ```
44
49
 
45
50
  ### With Sidekiq Scheduler
@@ -51,12 +56,20 @@ When using [sidekiq-scheduler](https://github.com/moove-it/sidekiq-scheduler), s
51
56
  # example
52
57
 
53
58
  :schedule:
54
- SidekiqEcsScaler::Worker:
59
+ SidekiqEcsScaleWorker:
55
60
  cron: "0 */15 * * * *"
56
61
  # It is safe to set this queue to have a higher priority than the monitored queue.
57
62
  queue: scheduler
58
63
  ```
59
64
 
65
+ ### About AWS IAM Policy
66
+
67
+ The task role of ECS task that runs Sidekiq workers requires the following permissions:
68
+
69
+ - `ecs:DescribeTasks`
70
+ - `ecs:DescribeServices`
71
+ - `ecs:UpdateService`
72
+
60
73
  ## Development
61
74
 
62
75
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/Rakefile CHANGED
@@ -12,8 +12,11 @@ RuboCop::RakeTask.new(:lint) do |t|
12
12
  t.options = %w[--parallel]
13
13
  end
14
14
  namespace :lint do
15
- desc "Lint fix (Rubocop)"
16
- task fix: :auto_correct
15
+ desc "Lint with fix (Rubocop)"
16
+ task fix: :autocorrect
17
+
18
+ desc "Lint with unsafe fix (Rubocop)"
19
+ task fixall: :autocorrect_all
17
20
  end
18
21
 
19
22
  # steep
@@ -32,8 +35,12 @@ end
32
35
  require "yard"
33
36
  desc "document"
34
37
  task :doc do
35
- YARD::CLI::CommandParser.run
36
- `yard`.lines(chomp: true).last.match(/\d+/)[0].to_i == 100 || exit(1)
38
+ io = StringIO.new
39
+ YARD::Logger.instance(io)
40
+ YARD::CLI::CommandParser.run(*%w[stats --list-undoc])
41
+ result = io.tap(&:rewind).read
42
+ $stdout.puts(result)
43
+ result.lines(chomp: true).last.strip == "100.00% documented" || exit(1)
37
44
  end
38
45
 
39
46
  task default: %i[lint typecheck spec doc]
data/Steepfile CHANGED
@@ -6,4 +6,6 @@ target :lib do
6
6
  check "lib"
7
7
 
8
8
  library "json"
9
+ library "logger"
10
+ library "monitor"
9
11
  end
data/docker-compose.yml CHANGED
@@ -1,9 +1,9 @@
1
1
  version: "3"
2
2
 
3
3
  services:
4
- sidekiq-ecs-scaler:
4
+ gem:
5
5
  build:
6
6
  context: .
7
7
  volumes:
8
- - .:/usr/src/sidekiq-ecs-scaler
8
+ - .:/usr/src/gem
9
9
  command: /bin/bash
@@ -1,40 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "uri"
4
- require "net/http"
5
- require "json"
6
- require "sidekiq"
7
- require "sidekiq/api"
8
- require "aws-sdk-ecs"
9
- require_relative "sidekiq-ecs-scaler/version"
10
- require_relative "sidekiq-ecs-scaler/task_meta_v4"
11
- require_relative "sidekiq-ecs-scaler/configuration"
12
- require_relative "sidekiq-ecs-scaler/client"
13
- require_relative "sidekiq-ecs-scaler/worker"
14
-
15
- # SidekiqEcsScaler
16
- module SidekiqEcsScaler
17
- # SidekiqEcsScaler::Error
18
- class Error < StandardError; end
19
-
20
- class << self
21
- # @return [SidekiqEcsScaler::Configuration]
22
- def config
23
- @config ||= Configuration.new
24
- end
25
-
26
- # @yieldparam config [SidekiqEcsScaler::Configuration]
27
- # @yieldreturn [void]
28
- # @return [void]
29
- def configure
30
- raise Error, "No block is given!" unless block_given?
31
-
32
- yield config
33
- end
34
-
35
- # @return [SidekiqEcsScaler::Client]
36
- def client
37
- Client.new(config)
38
- end
39
- end
40
- end
3
+ require "sidekiq_ecs_scaler"
@@ -0,0 +1,97 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SidekiqEcsScaler
4
+ # SidekiqEcsScaler::Client
5
+ class Client
6
+ class << self
7
+ # @param keywords [Hash]
8
+ # @return [Integer]
9
+ def update_desired_count(**keywords)
10
+ new(SidekiqEcsScaler::Configuration.new(**keywords)).update_desired_count
11
+ end
12
+ end
13
+
14
+ # @param config [SidekiqEcsScaler::Configuration]
15
+ # @return [void]
16
+ def initialize(config)
17
+ @config = config
18
+ end
19
+
20
+ # @return [Integer]
21
+ def update_desired_count
22
+ desired_count = desired_count_by_latency
23
+ service = describe_service
24
+
25
+ if service.desired_count == desired_count
26
+ not_change_log(desired_count)
27
+ else
28
+ update_service(service: service, desired_count: desired_count)
29
+ change_log(service.desired_count, desired_count)
30
+ end
31
+
32
+ desired_count
33
+ end
34
+
35
+ private
36
+
37
+ # @!attribute [r] config
38
+ # @return [SidekiqEcsScaler::Configuration]
39
+ attr_reader :config
40
+
41
+ # @return [Float]
42
+ def queue_latency
43
+ Sidekiq::Queue.new(config.queue_name).latency
44
+ end
45
+
46
+ # @return [Integer]
47
+ def desired_count_by_latency
48
+ desired_count_list.at((queue_latency.to_f / config.latency_per_step_count).floor.to_i) || config.max_count
49
+ end
50
+
51
+ # @return [Array<Integer>]
52
+ def desired_count_list
53
+ config.min_count.step(config.max_count, config.step_count).to_a
54
+ end
55
+
56
+ # @return [String]
57
+ def describe_service_name
58
+ task_meta = config.task_meta
59
+ task = config.ecs_client.describe_tasks({ cluster: task_meta.cluster, tasks: [task_meta.task_arn] }).tasks.first
60
+ raise Error, "Task(#{task_meta.task_arn}) does not exist in cluster!" if task.nil?
61
+
62
+ task.group.delete_prefix("service:")
63
+ end
64
+
65
+ # @return [Aws::ECS::Types::Service]
66
+ def describe_service
67
+ service_name = describe_service_name
68
+ config.ecs_client.describe_services(
69
+ { cluster: config.task_meta.cluster, services: [service_name] }
70
+ ).services.first || (raise Error, "Service(#{service_name}) does not exist in cluster!")
71
+ end
72
+
73
+ # @param service [Aws::ECS::Types::Service]
74
+ # @param desired_count [Integer]
75
+ # @return [Aws::ECS::Types::UpdateServiceResponse]
76
+ def update_service(service:, desired_count:)
77
+ config.ecs_client.update_service(
78
+ { cluster: service.cluster_arn, service: service.service_name, desired_count: desired_count }
79
+ )
80
+ end
81
+
82
+ # @param count [Integer]
83
+ # @return [void]
84
+ def not_change_log(count)
85
+ config.logger.info("SidekiqEcsScaler doesn't have updated the desired count of tasks from #{count}.")
86
+ end
87
+
88
+ # @param before_count [Integer]
89
+ # @param after_count [Integer]
90
+ # @return [void]
91
+ def change_log(before_count, after_count)
92
+ config.logger.info(
93
+ "SidekiqEcsScaler has updated the desired count of tasks from #{before_count} to #{after_count}."
94
+ )
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,147 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SidekiqEcsScaler
4
+ # SidekiqEcsScaler::Configuration
5
+ class Configuration
6
+ # @!attribute [r] queue_name
7
+ # @return [String]
8
+ attr_reader :queue_name
9
+ # @!attribute [r] min_count
10
+ # @return [Integer]
11
+ attr_reader :min_count
12
+ # @!attribute [r] max_count
13
+ # @return [Integer]
14
+ attr_reader :max_count
15
+ # @!attribute [r] step_count
16
+ # @return [Integer]
17
+ attr_reader :step_count
18
+ # @!attribute [r] max_latency
19
+ # @return [Integer]
20
+ attr_reader :max_latency
21
+ # @!attribute [r] task_meta
22
+ # @return [SidekiqEcsScaler::TaskMetaV4]
23
+ attr_reader :task_meta
24
+ # @!attribute [r] ecs_client
25
+ # @return [Aws::Ecs::Client]
26
+ attr_reader :ecs_client
27
+ # @!attribute [r] logger
28
+ # @return [Logger]
29
+ attr_reader :logger
30
+
31
+ # @param queue_name [String]
32
+ # @param min_count [Integer]
33
+ # @param max_count [Integer]
34
+ # @param step_count [Integer]
35
+ # @param max_latency [Integer]
36
+ # @param task_meta [SidekiqEcsScaler::TaskMetaV4]
37
+ # @param ecs_client [Aws::ECS::Client]
38
+ # @param logger [Logger]
39
+ # @return [void]
40
+ def initialize( # rubocop:disable Metrics/ParameterLists
41
+ queue_name: "default",
42
+ min_count: 1,
43
+ max_count: 1,
44
+ step_count: 1,
45
+ max_latency: 3_600,
46
+ task_meta: TaskMetaV4.build_or_null,
47
+ ecs_client: Aws::ECS::Client.new,
48
+ logger: Sidekiq.logger
49
+ )
50
+ self.queue_name = queue_name
51
+ self.min_count = min_count
52
+ self.max_count = max_count
53
+ self.step_count = step_count
54
+ self.max_latency = max_latency
55
+ self.task_meta = task_meta
56
+ self.ecs_client = ecs_client
57
+ self.logger = logger
58
+ end
59
+
60
+ # @return [Integer]
61
+ def latency_per_step_count
62
+ (max_latency / ((1 + max_count - min_count).to_f / step_count).ceil).tap do |value|
63
+ value.positive? || (raise Error, "latency per count isn't positive!")
64
+ end
65
+ end
66
+
67
+ private
68
+
69
+ # @param logger [Logger]
70
+ # @return [void]
71
+ def logger=(logger)
72
+ raise ArgumentError unless logger.is_a?(Logger)
73
+
74
+ @logger = logger
75
+ end
76
+
77
+ # @param queue_name [String]
78
+ # @return [void]
79
+ def queue_name=(queue_name)
80
+ raise ArgumentError unless queue_name.instance_of?(String)
81
+
82
+ @queue_name = queue_name
83
+ end
84
+
85
+ # @param min_count [Integer]
86
+ # @return [void]
87
+ # @raise [ArgumentError]
88
+ def min_count=(min_count)
89
+ assert_positive_number!(min_count)
90
+
91
+ @min_count = min_count
92
+ end
93
+
94
+ # @param max_count [Integer]
95
+ # @return [void]
96
+ # @raise [ArgumentError]
97
+ def max_count=(max_count)
98
+ assert_positive_number!(max_count)
99
+
100
+ @max_count = max_count
101
+ @min_count = max_count if max_count < min_count
102
+ end
103
+
104
+ # @param step_count [Integer]
105
+ # @return [void]
106
+ # @raise [ArgumentError]
107
+ def step_count=(step_count)
108
+ assert_positive_number!(step_count)
109
+
110
+ @step_count = step_count
111
+ end
112
+
113
+ # @param max_latency [Integer]
114
+ # @return [void]
115
+ # @raise [ArgumentError]
116
+ def max_latency=(max_latency)
117
+ raise ArgumentError if max_count > max_latency
118
+
119
+ @max_latency = max_latency
120
+ end
121
+
122
+ # @param ecs_client [Aws::ECS::Client]
123
+ # @return [void]
124
+ # @raise [ArgumentError]
125
+ def ecs_client=(ecs_client)
126
+ raise ArgumentError unless ecs_client.is_a?(Aws::ECS::Client)
127
+
128
+ @ecs_client = ecs_client
129
+ end
130
+
131
+ # @param task_meta [SidekiqEcsScaler::TaskMetaV4]
132
+ # @return [void]
133
+ # @raise [ArgumentError]
134
+ def task_meta=(task_meta)
135
+ raise ArgumentError unless task_meta.is_a?(SidekiqEcsScaler::TaskMetaV4)
136
+
137
+ @task_meta = task_meta
138
+ end
139
+
140
+ # @param number [Integer]
141
+ # @return [void]
142
+ # @raise [ArgumentError]
143
+ def assert_positive_number!(number)
144
+ raise ArgumentError unless number.positive?
145
+ end
146
+ end
147
+ end
@@ -11,7 +11,8 @@ module SidekiqEcsScaler
11
11
  # @return [SidekiqEcsScaler::TaskMetaV4, nil]
12
12
  def build_or_null
13
13
  ENV.fetch("ECS_CONTAINER_METADATA_URI_V4", nil)&.then do |uri|
14
- new(JSON.parse(Net::HTTP.get(URI.parse("#{uri}/task"))))
14
+ resp = JSON.parse(Net::HTTP.get(URI.parse("#{uri}/task")))
15
+ new(cluster: resp.fetch("Cluster"), task_arn: resp.fetch("TaskARN"))
15
16
  end
16
17
  rescue StandardError
17
18
  nil
@@ -25,11 +26,12 @@ module SidekiqEcsScaler
25
26
  # @return [String]
26
27
  attr_reader :task_arn
27
28
 
28
- # @param resp [Hash]
29
+ # @param cluster [String]
30
+ # @param task_arn [String]
29
31
  # @return [void]
30
- def initialize(resp)
31
- @cluster = resp.fetch("Cluster")
32
- @task_arn = resp.fetch("TaskARN")
32
+ def initialize(cluster:, task_arn:)
33
+ @cluster = cluster
34
+ @task_arn = task_arn
33
35
  end
34
36
  end
35
37
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module SidekiqEcsScaler
4
4
  # @return [String]
5
- VERSION = "0.1.0"
5
+ VERSION = "0.3.0"
6
6
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "logger"
4
+ require "uri"
5
+ require "net/http"
6
+ require "json"
7
+ require "sidekiq"
8
+ require "sidekiq/api"
9
+ require "aws-sdk-ecs"
10
+ require_relative "sidekiq_ecs_scaler/version"
11
+ require_relative "sidekiq_ecs_scaler/task_meta_v4"
12
+ require_relative "sidekiq_ecs_scaler/configuration"
13
+ require_relative "sidekiq_ecs_scaler/client"
14
+
15
+ # SidekiqEcsScaler
16
+ module SidekiqEcsScaler
17
+ # SidekiqEcsScaler::Error
18
+ class Error < StandardError; end
19
+ end
@@ -0,0 +1,76 @@
1
+ ---
2
+ path: ".gem_rbs_collection"
3
+ gems:
4
+ - name: aws-sdk-core
5
+ version: '3'
6
+ source:
7
+ type: git
8
+ name: ruby/gem_rbs_collection
9
+ revision: 13ae8cd19056d62358a9d4836106b8b31219fc1e
10
+ remote: https://github.com/ruby/gem_rbs_collection.git
11
+ repo_dir: gems
12
+ - name: cgi
13
+ version: '0'
14
+ source:
15
+ type: stdlib
16
+ - name: concurrent-ruby
17
+ version: '1.1'
18
+ source:
19
+ type: git
20
+ name: ruby/gem_rbs_collection
21
+ revision: 13ae8cd19056d62358a9d4836106b8b31219fc1e
22
+ remote: https://github.com/ruby/gem_rbs_collection.git
23
+ repo_dir: gems
24
+ - name: connection_pool
25
+ version: '2.4'
26
+ source:
27
+ type: git
28
+ name: ruby/gem_rbs_collection
29
+ revision: 13ae8cd19056d62358a9d4836106b8b31219fc1e
30
+ remote: https://github.com/ruby/gem_rbs_collection.git
31
+ repo_dir: gems
32
+ - name: logger
33
+ version: '0'
34
+ source:
35
+ type: stdlib
36
+ - name: monitor
37
+ version: '0'
38
+ source:
39
+ type: stdlib
40
+ - name: rack
41
+ version: '2.2'
42
+ source:
43
+ type: git
44
+ name: ruby/gem_rbs_collection
45
+ revision: 13ae8cd19056d62358a9d4836106b8b31219fc1e
46
+ remote: https://github.com/ruby/gem_rbs_collection.git
47
+ repo_dir: gems
48
+ - name: redis
49
+ version: '4.2'
50
+ source:
51
+ type: git
52
+ name: ruby/gem_rbs_collection
53
+ revision: 13ae8cd19056d62358a9d4836106b8b31219fc1e
54
+ remote: https://github.com/ruby/gem_rbs_collection.git
55
+ repo_dir: gems
56
+ - name: sidekiq
57
+ version: '6.3'
58
+ source:
59
+ type: git
60
+ name: ruby/gem_rbs_collection
61
+ revision: 13ae8cd19056d62358a9d4836106b8b31219fc1e
62
+ remote: https://github.com/ruby/gem_rbs_collection.git
63
+ repo_dir: gems
64
+ - name: tempfile
65
+ version: '0'
66
+ source:
67
+ type: stdlib
68
+ - name: timeout
69
+ version: '0'
70
+ source:
71
+ type: stdlib
72
+ - name: uri
73
+ version: '0'
74
+ source:
75
+ type: stdlib
76
+ gemfile_lock_path: Gemfile.lock
@@ -0,0 +1,17 @@
1
+ # Download sources
2
+ sources:
3
+ - type: git
4
+ name: ruby/gem_rbs_collection
5
+ remote: https://github.com/ruby/gem_rbs_collection.git
6
+ revision: main
7
+ repo_dir: gems
8
+
9
+ # You can specify local directories as sources also.
10
+ # - type: local
11
+ # path: path/to/your/local/repository
12
+
13
+ # A directory to install the downloaded RBSs
14
+ path: .gem_rbs_collection
15
+
16
+ gems:
17
+ - name: redis
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "lib/sidekiq-ecs-scaler/version"
3
+ require_relative "lib/sidekiq_ecs_scaler/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "sidekiq-ecs-scaler"
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.require_paths = ["lib"]
31
31
 
32
32
  spec.add_dependency "aws-sdk-ecs", "> 1", "< 2"
33
- spec.add_dependency "sidekiq", "> 5", "< 7"
33
+ spec.add_dependency "sidekiq", "> 5", "< 8"
34
34
 
35
35
  # For more information and examples about making a new gem, checkout our
36
36
  # guide at: https://bundler.io/guides/creating_gem.html
@@ -4,16 +4,12 @@ module SidekiqEcsScaler
4
4
  class Error < StandardError
5
5
  end
6
6
 
7
- def self.config: () -> ::SidekiqEcsScaler::Configuration
8
-
9
- def self.configure: () { (::SidekiqEcsScaler::Configuration) -> void } -> void
10
-
11
- def self.client: () -> ::SidekiqEcsScaler::Client
12
-
13
7
  class Client
8
+ def self.update_desired_count: (**untyped) -> ::Integer
9
+
14
10
  def initialize: (::SidekiqEcsScaler::Configuration) -> void
15
11
 
16
- def update_desired_count: () -> ::Integer?
12
+ def update_desired_count: () -> ::Integer
17
13
 
18
14
  private
19
15
 
@@ -23,43 +19,68 @@ module SidekiqEcsScaler
23
19
 
24
20
  def desired_count_by_latency: () -> ::Integer
25
21
 
26
- def service_name: () -> ::String
22
+ def desired_count_list: () -> ::Array[::Integer]
23
+
24
+ def describe_service_name: () -> ::String
27
25
 
28
26
  def describe_service: () -> ::Aws::ECS::Types::Service
29
27
 
30
28
  def update_service: (service: ::Aws::ECS::Types::Service, desired_count: ::Integer) -> ::Aws::ECS::Types::UpdateServiceResponse
29
+
30
+ def not_change_log: (::Integer) -> void
31
+
32
+ def change_log: (::Integer, ::Integer) -> void
31
33
  end
32
34
 
33
35
  class Configuration
34
- attr_accessor queue_name: ::String
36
+ attr_reader queue_name: ::String
35
37
 
36
38
  attr_reader min_count: ::Integer
37
39
 
38
40
  attr_reader max_count: ::Integer
39
41
 
42
+ attr_reader step_count: ::Integer
43
+
40
44
  attr_reader max_latency: ::Integer
41
45
 
42
- attr_reader task_meta: ::SidekiqEcsScaler::TaskMetaV4?
46
+ attr_reader task_meta: ::SidekiqEcsScaler::TaskMetaV4
47
+
48
+ attr_reader logger: ::Logger
43
49
 
44
50
  attr_reader ecs_client: ::Aws::ECS::Client
45
51
 
46
- def initialize: () -> void
52
+ def initialize: (
53
+ ?queue_name: ::String,
54
+ ?min_count: ::Integer,
55
+ ?max_count: ::Integer,
56
+ ?step_count: ::Integer,
57
+ ?max_latency: ::Integer,
58
+ ?task_meta: ::SidekiqEcsScaler::TaskMetaV4,
59
+ ?ecs_client: ::Aws::ECS::Client,
60
+ ?logger: ::Logger
61
+ ) -> void
47
62
 
48
- def min_count=: (::Integer) -> void
63
+ def latency_per_step_count: () -> ::Integer
49
64
 
50
- def max_count=: (::Integer) -> void
65
+ private
51
66
 
52
- def max_latency=: (::Integer) -> void
67
+ def assert_positive_number!: (::Integer) -> void
53
68
 
54
- def ecs_client=: (::Aws::ECS::Client) -> void
69
+ def logger=: (::Logger) -> void
70
+
71
+ def queue_name=: (::String) -> void
72
+
73
+ def min_count=: (::Integer) -> void
74
+
75
+ def max_count=: (::Integer) -> void
55
76
 
56
- def latency_per_count: () -> ::Integer
77
+ def step_count=: (::Integer) -> void
57
78
 
58
- def task_meta!: () -> ::SidekiqEcsScaler::TaskMetaV4
79
+ def max_latency=: (::Integer) -> void
59
80
 
60
- def sidekiq_options: () -> ::Hash[untyped, untyped]
81
+ def task_meta=: (::SidekiqEcsScaler::TaskMetaV4) -> void
61
82
 
62
- def sidekiq_options=: (::Hash[untyped, untyped]) -> void
83
+ def ecs_client=: (::Aws::ECS::Client) -> void
63
84
  end
64
85
 
65
86
  class TaskMetaV4
@@ -69,14 +90,6 @@ module SidekiqEcsScaler
69
90
 
70
91
  attr_reader task_arn: ::String
71
92
 
72
- def initialize: (::Hash[untyped, untyped]) -> void
73
- end
74
-
75
- class Worker
76
- include ::Sidekiq::Worker
77
-
78
- def self.sidekiq_options: (?::Hash[untyped, untyped]) -> ::Hash[untyped, untyped]
79
-
80
- def perform: () -> ::Integer?
93
+ def initialize: (cluster: ::String, task_arn: ::String) -> void
81
94
  end
82
95
  end
data/sig-private/uri.rbs CHANGED
@@ -1,5 +1,6 @@
1
1
  module ::URI
2
2
  def self.parse: (String) -> ::URI::HTTP
3
+ | ...
3
4
 
4
5
  class ::URI::HTTP
5
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-ecs-scaler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - shoma07
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-29 00:00:00.000000000 Z
11
+ date: 2024-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-ecs
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: '5'
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '7'
42
+ version: '8'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: '5'
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '7'
52
+ version: '8'
53
53
  description: auto scaler of sidekiq worker deploymented to aws ecs
54
54
  email:
55
55
  - 23730734+shoma07@users.noreply.github.com
@@ -74,15 +74,16 @@ files:
74
74
  - docker-compose.yml
75
75
  - exe/sidekiq-ecs-scaler
76
76
  - lib/sidekiq-ecs-scaler.rb
77
- - lib/sidekiq-ecs-scaler/client.rb
78
- - lib/sidekiq-ecs-scaler/configuration.rb
79
- - lib/sidekiq-ecs-scaler/task_meta_v4.rb
80
- - lib/sidekiq-ecs-scaler/version.rb
81
- - lib/sidekiq-ecs-scaler/worker.rb
77
+ - lib/sidekiq_ecs_scaler.rb
78
+ - lib/sidekiq_ecs_scaler/client.rb
79
+ - lib/sidekiq_ecs_scaler/configuration.rb
80
+ - lib/sidekiq_ecs_scaler/task_meta_v4.rb
81
+ - lib/sidekiq_ecs_scaler/version.rb
82
+ - rbs_collection.lock.yaml
83
+ - rbs_collection.yaml
82
84
  - sidekiq-ecs-scaler.gemspec
83
85
  - sig-private/aws-sdk-ecs.rbs
84
86
  - sig-private/net/http.rbs
85
- - sig-private/sidekiq.rbs
86
87
  - sig-private/uri.rbs
87
88
  - sig/sidekiq-ecs-scaler.rbs
88
89
  homepage: https://github.com/shoma07/sidekiq-ecs-scaler
@@ -105,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
106
  - !ruby/object:Gem::Version
106
107
  version: '0'
107
108
  requirements: []
108
- rubygems_version: 3.2.32
109
+ rubygems_version: 3.4.10
109
110
  signing_key:
110
111
  specification_version: 4
111
112
  summary: auto scaler of sidekiq worker deploymented to aws ecs
@@ -1,74 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SidekiqEcsScaler
4
- # SidekiqEcsScaler::Client
5
- class Client
6
- # @param config [SidekiqEcsScaler::Configuration]
7
- # @return [void]
8
- def initialize(config)
9
- @config = config
10
- end
11
-
12
- # @return [Integer, nil]
13
- def update_desired_count
14
- return unless config.task_meta
15
-
16
- desired_count_by_latency.then do |desired_count|
17
- describe_service.then do |service|
18
- update_service(service: service, desired_count: desired_count) if service.desired_count != desired_count
19
-
20
- desired_count
21
- end
22
- end
23
- end
24
-
25
- private
26
-
27
- # @!attribute [r] config
28
- # @return [SidekiqEcsScaler::Configuration]
29
- attr_reader :config
30
-
31
- # @return [Float]
32
- def queue_latency
33
- Sidekiq::Queue.new(config.queue_name).latency
34
- end
35
-
36
- # @return [Integer]
37
- def desired_count_by_latency
38
- (config.min_count..config.max_count).to_a.at(
39
- (queue_latency.to_f / config.latency_per_count).floor.to_i
40
- ) || config.max_count
41
- end
42
-
43
- # @return [String]
44
- def service_name
45
- config.task_meta!.then do |task_meta|
46
- config.ecs_client.describe_tasks(
47
- { cluster: task_meta.cluster, tasks: [task_meta.task_arn] }
48
- ).tasks.first&.then { |task| task.group.delete_prefix("service:") } || (
49
- raise Error, "Task(#{task_meta.task_arn}) does not exist in cluster!"
50
- )
51
- end
52
- end
53
-
54
- # @return [Aws::ECS::Types::Service]
55
- def describe_service
56
- config.ecs_client.describe_services(
57
- { cluster: config.task_meta!.cluster, services: [service_name] }
58
- ).services.first || (raise Error, "Service(#{service_name}) does not exist in cluster!")
59
- end
60
-
61
- # @param service [Aws::ECS::Types::Service]
62
- # @param desired_count [Integer]
63
- # @return [Aws::ECS::Types::UpdateServiceResponse]
64
- def update_service(service:, desired_count:)
65
- config.ecs_client.update_service(
66
- {
67
- cluster: service.cluster_arn,
68
- service: service.service_name,
69
- desired_count: desired_count
70
- }
71
- )
72
- end
73
- end
74
- end
@@ -1,106 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SidekiqEcsScaler
4
- # SidekiqEcsScaler::Configuration
5
- class Configuration
6
- # @!attribute [r] queue_name
7
- # @return [String]
8
- attr_reader :queue_name
9
- # @!attribute [r] min_count
10
- # @return [Integer]
11
- attr_reader :min_count
12
- # @!attribute [r] max_count
13
- # @return [Integer]
14
- attr_reader :max_count
15
- # @!attribute [r] max_latency
16
- # @return [Integer]
17
- attr_reader :max_latency
18
- # @!attribute [r] task_meta
19
- # @return [SidekiqEcsScaler::TaskMetaV4, nil]
20
- attr_reader :task_meta
21
- # @!attribute [r] ecs_client
22
- # @return [Aws::ECS::Client]
23
- attr_reader :ecs_client
24
-
25
- # @return [void]
26
- def initialize
27
- @queue_name = "default"
28
- @min_count = 1
29
- @max_count = 1
30
- @max_latency = 3600
31
- @ecs_client = Aws::ECS::Client.new
32
- @task_meta = TaskMetaV4.build_or_null
33
- end
34
-
35
- # @param queue_name [String]
36
- # @return [void]
37
- def queue_name=(queue_name)
38
- raise ArgumentError unless queue_name.instance_of?(String)
39
-
40
- @queue_name = queue_name
41
- end
42
-
43
- # @param min_count [Integer]
44
- # @return [void]
45
- # @raise [ArgumentError]
46
- def min_count=(min_count)
47
- raise ArgumentError unless min_count.positive?
48
-
49
- @min_count = min_count
50
- @max_count = min_count if min_count > max_count
51
- end
52
-
53
- # @param max_count [Integer]
54
- # @return [void]
55
- # @raise [ArgumentError]
56
- def max_count=(max_count)
57
- raise ArgumentError unless max_count.positive?
58
-
59
- @max_count = max_count
60
- @min_count = max_count if max_count < min_count
61
- end
62
-
63
- # @param max_latency [Integer]
64
- # @return [void]
65
- # @raise [ArgumentError]
66
- def max_latency=(max_latency)
67
- raise ArgumentError if max_count > max_latency
68
-
69
- @max_latency = max_latency
70
- end
71
-
72
- # @param ecs_client [Aws::ECS::Client]
73
- # @return [void]
74
- # @raise [ArgumentError]
75
- def ecs_client=(ecs_client)
76
- raise ArgumentError unless ecs_client.is_a?(Aws::ECS::Client)
77
-
78
- @ecs_client = ecs_client
79
- end
80
-
81
- # @return [Integer]
82
- def latency_per_count
83
- (max_latency / (1 + max_count - min_count)).tap do |value|
84
- value.positive? || (raise Error, "latency per count isn't positive!")
85
- end
86
- end
87
-
88
- # @return [SidekiqEcsScaler::TaskMetaV4]
89
- def task_meta!
90
- task_meta || (raise Error, "task metadata is null!")
91
- end
92
-
93
- # @return [Hash]
94
- def sidekiq_options
95
- ::SidekiqEcsScaler::Worker.sidekiq_options
96
- end
97
-
98
- # @param sidekiq_options [Hash]
99
- # @return [void]
100
- def sidekiq_options=(sidekiq_options)
101
- raise ArgumentError unless sidekiq_options.is_a?(Hash)
102
-
103
- ::SidekiqEcsScaler::Worker.sidekiq_options(sidekiq_options)
104
- end
105
- end
106
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SidekiqEcsScaler
4
- # SidekiqEcsScaler::Worker
5
- class Worker
6
- include Sidekiq::Worker
7
-
8
- # @return [Integer, nil]
9
- def perform
10
- SidekiqEcsScaler.client.update_desired_count
11
- end
12
- end
13
- end
@@ -1,11 +0,0 @@
1
- module Sidekiq
2
- module Worker
3
- def self.sidekiq_options: (?::Hash[untyped, untyped]) -> ::Hash[untyped, untyped]
4
- end
5
-
6
- class Queue
7
- def initialize: (::String) -> void
8
-
9
- def latency: () -> ::Float
10
- end
11
- end