web47core 3.2.3.44 → 3.2.3.45

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: 3adced90c2a22503ee987e0c720d5ea1e007f4fbc656dbc90bdc7fa7cf075ae8
4
- data.tar.gz: 9e3018472076d431cccfa4009d08ab6bfdb91e5bad5e803cf11a3d3de913847f
3
+ metadata.gz: 8870399f95e59eac84d25e3752f2e8694986a76c609471ce639d11d0939ff540
4
+ data.tar.gz: 37e7ff4979d9fda9e459969949e2b2108ce87eaee88ecb015dd36883c8384e07
5
5
  SHA512:
6
- metadata.gz: c8879b69e2ec9d801ee359c6be12100d80c6df3c45e849241acba09a17cc704049339b8fb68e6d4faf41c09e62ba60cc793d5ba21aca3dd4b7a0de0e644bd8ea
7
- data.tar.gz: 1535db52112c0f4f5019fc3b5d9230ab284c3938f27093543f3142f344cc26a61f840fc6e33663b4ef9de242de10b3633f83532bc5e78c46b4fc9df3d6227a03
6
+ metadata.gz: aa0b881dc84f4f54c6e18ab89f1719b633a5c1538871aa9c4079b5c8c4c84f7e69e1bbdd7e86ca13880cf454ea5b653ddd89a00caca8ebebb232ea2dbb5603f1
7
+ data.tar.gz: 3c3b5e02b342e9afa8dbccfab990f7d7d44e284eef1c59ea19ed79e42a74c3636e727a298f7f5dce073532e4365e501ea8da98640dd584639f11f1b6ae5af91d
@@ -5,10 +5,13 @@ require 'singleton'
5
5
  #
6
6
  # Resize the ECS worker service from the current thread.
7
7
  #
8
- # check runs after the primary cron server has launched due jobs.
9
- # warm_up raises the fleet to a floor. bump_worker adds one worker.
10
- # Neither call lowers a fleet that is already larger, except check when the
11
- # ladder maps the queue to zero workers.
8
+ # check runs after the primary cron server has launched due jobs and follows
9
+ # the worker ladder. It does not shrink the fleet while any job is still
10
+ # queued, including when the ladder maps that depth to zero workers. It
11
+ # scales to zero only when the queue is empty.
12
+ # warm_up raises the fleet to at least the requested floor. bump_worker adds
13
+ # one worker. Neither call consults the ladder or the queue, and neither
14
+ # lowers a fleet that is already larger.
12
15
  #
13
16
  # A host project replaces the ladder at boot:
14
17
  #
@@ -59,21 +62,23 @@ class AutoScaler
59
62
  def check
60
63
  return unless configured?
61
64
 
62
- apply_target(desired_for(delayed_jobs_count))
65
+ job_count = delayed_jobs_count
66
+ apply_target(desired_for(job_count), job_count: job_count)
63
67
  end
64
68
 
65
69
  #
66
- # Raise the ECS desired count to at least min. Never lowers the fleet.
70
+ # Raise the ECS desired count to at least min. Ignores the ladder and the
71
+ # queue. Never lowers the fleet.
67
72
  #
68
73
  def warm_up(min: 1)
69
74
  return unless configured?
70
75
 
71
- target = [[min.to_i, 1].max, max_worker_count].min
72
- scale_to(target)
76
+ scale_to([min.to_i, 1].max)
73
77
  end
74
78
 
75
79
  #
76
- # Add one worker to the live ECS desired count, capped at the ladder maximum.
80
+ # Add one worker to the live ECS desired count. Ignores the ladder and the
81
+ # queue.
77
82
  #
78
83
  def bump_worker
79
84
  return unless configured?
@@ -81,7 +86,7 @@ class AutoScaler
81
86
  current = live_desired_count
82
87
  return if current.nil?
83
88
 
84
- scale_to([current + 1, max_worker_count].min, current: current)
89
+ scale_to(current + 1, current: current)
85
90
  end
86
91
 
87
92
  def reset
@@ -90,12 +95,22 @@ class AutoScaler
90
95
 
91
96
  private
92
97
 
93
- def apply_target(target)
94
- record_desired(target)
98
+ def apply_target(target, job_count:)
95
99
  current = live_desired_count
96
- return if current.nil?
97
- return if target.positive? && target <= current
98
- return if target.zero? && current.zero?
100
+ if current.nil?
101
+ record_desired(target)
102
+ return
103
+ end
104
+
105
+ # Keep the live fleet while any job remains. The ladder still chooses a
106
+ # larger fleet. Scale down only once the queue is empty.
107
+ if job_count.positive? && target < current
108
+ record_desired(current)
109
+ return
110
+ end
111
+
112
+ record_desired(target)
113
+ return if target == current
99
114
 
100
115
  update_service(target)
101
116
  end
@@ -115,10 +130,6 @@ class AutoScaler
115
130
  worker_ladder.last.last
116
131
  end
117
132
 
118
- def max_worker_count
119
- worker_ladder.map(&:last).max
120
- end
121
-
122
133
  def worker_ladder
123
134
  Web47core::Config.worker_ladder.presence || DEFAULT_WORKER_LADDER
124
135
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Web47core
4
- VERSION = '3.2.3.44'
4
+ VERSION = '3.2.3.45'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web47core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.3.44
4
+ version: 3.2.3.45
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Schroeder