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 +4 -4
- data/lib/app/services/auto_scaler.rb +30 -19
- data/lib/web47core/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8870399f95e59eac84d25e3752f2e8694986a76c609471ce639d11d0939ff540
|
|
4
|
+
data.tar.gz: 37e7ff4979d9fda9e459969949e2b2108ce87eaee88ecb015dd36883c8384e07
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
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
|
|
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(
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
data/lib/web47core/version.rb
CHANGED