web47core 3.2.3.44 → 3.2.3.46

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: 5cb60aaf9b363d9d95a53e02cd2875e60b79f26344d64e08f6ba2ab8dce88e28
4
+ data.tar.gz: 383b9f556359a6578d06ea3b319c0382016e6638d2c914da04684d34a7c9d933
5
5
  SHA512:
6
- metadata.gz: c8879b69e2ec9d801ee359c6be12100d80c6df3c45e849241acba09a17cc704049339b8fb68e6d4faf41c09e62ba60cc793d5ba21aca3dd4b7a0de0e644bd8ea
7
- data.tar.gz: 1535db52112c0f4f5019fc3b5d9230ab284c3938f27093543f3142f344cc26a61f840fc6e33663b4ef9de242de10b3633f83532bc5e78c46b4fc9df3d6227a03
6
+ metadata.gz: 670ea6d949445923fe1a9ec0f0a9b27d48a9ad6a73ac5dd3050088e1adc13fc9393f7d67991826db3587a864319b112700c8bfd2fa761bcf47437c17c63810ff
7
+ data.tar.gz: 4565290e61d30d10a39be0584e7b6fe200fe76edfbf769f42e6e0c4af3544218a4be89b7049d6fe4d66237cca637f09e27511b184ef1827baa00d6abfa0fd5e7
@@ -4,6 +4,7 @@
4
4
  # Return the status of the server
5
5
  #
6
6
  class StatusController < ActionController::Base
7
+ helper SvgIconHelper
7
8
  protect_from_forgery with: :exception
8
9
  #
9
10
  # Main (and only) page
@@ -40,11 +41,11 @@ class StatusController < ActionController::Base
40
41
  def ui_decorators(components)
41
42
  components.each do |key, values|
42
43
  if values[:success]
43
- components[key][:icon_name] = 'check_circle'
44
- components[key][:icon_color] = 'green-text'
44
+ components[key][:icon_name] = 'circle-check'
45
+ components[key][:icon_color] = :green
45
46
  else
46
- components[key][:icon_name] = 'error'
47
- components[key][:icon_color] = 'red-text'
47
+ components[key][:icon_name] = 'circle-x'
48
+ components[key][:icon_color] = :red
48
49
  end
49
50
  end
50
51
  end
@@ -3,33 +3,25 @@
3
3
  module SvgIconHelper
4
4
  # @abstract Render the appropriate icon based on the name and type
5
5
  # @return [View]
6
- def svg_icon(name, size: 24, type: :outline, classes: [], color: 'currentColor', stroke_width: 2)
6
+ def svg_icon(name, size: 24, type: :outline, classes: [], color: 'currentColor', stroke_width: 2, cached: true)
7
7
  return if name.blank?
8
8
 
9
+ unless cached
10
+ return fetch_svg_icon(name, size: size, type: type, classes: classes, color: color, stroke_width: stroke_width,
11
+ cached: false)
12
+ end
13
+
9
14
  key = ['svg_icon', name, size.to_s, type.to_s, classes.to_s, color, stroke_width.to_s].join(':')
10
15
  Rails.cache.fetch(key, expires_in: 15.minutes) do
11
16
  fetch_svg_icon(name, size: size, type: type, classes: classes, color: color, stroke_width: stroke_width)
12
17
  end
13
18
  end
14
19
 
15
- def fetch_svg_icon(name, size: 24, type: :outline, classes: [], color: 'currentColor', stroke_width: 2)
20
+ def fetch_svg_icon(name, size: 24, type: :outline, classes: [], color: 'currentColor', stroke_width: 2, cached: true)
16
21
  return if name.blank?
17
22
 
18
23
  classes = classes.compact.flatten.join(' ')
19
- key = "icon_partial_path:#{name}:#{type}"
20
- (partial, stroke) = Rails.cache.fetch(key, expires_in: 15.minutes) do
21
- preferred_path = if I18n.exists?("nav.icons.#{name}")
22
- "icons/#{I18n.t("nav.icons.#{name}")}"
23
- else
24
- "icons/#{type}/#{name}"
25
- end
26
- outline_path = "icons/outline/#{name}"
27
- filled_path = "icons/filled/#{name}"
28
-
29
- [preferred_path, outline_path, filled_path].collect do |path|
30
- [preferred_path, color] if lookup_context.exists?(path, [], true)
31
- end.compact.first
32
- end
24
+ partial, stroke = icon_partial(name, type, color, cached: cached)
33
25
  if partial.blank?
34
26
  partial = 'icons/outline/bug'
35
27
  stroke = 'red'
@@ -42,6 +34,7 @@ module SvgIconHelper
42
34
  class: classes,
43
35
  fill: 'none',
44
36
  stroke: stroke,
37
+ style: "color: #{stroke}",
45
38
  'stroke-width': stroke_width,
46
39
  'stroke-linecap': 'round',
47
40
  'stroke-linejoin': 'round',
@@ -65,4 +58,23 @@ module SvgIconHelper
65
58
  render 'icons/outline/bug'
66
59
  end
67
60
  end
61
+
62
+ def icon_partial(name, type, color, cached:)
63
+ lookup = lambda do
64
+ preferred_path = if I18n.exists?("nav.icons.#{name}")
65
+ "icons/#{I18n.t("nav.icons.#{name}")}"
66
+ else
67
+ "icons/#{type}/#{name}"
68
+ end
69
+ outline_path = "icons/outline/#{name}"
70
+ filled_path = "icons/filled/#{name}"
71
+
72
+ [preferred_path, outline_path, filled_path].collect do |path|
73
+ [preferred_path, color] if lookup_context.exists?(path, [], true)
74
+ end.compact.first
75
+ end
76
+ return lookup.call unless cached
77
+
78
+ Rails.cache.fetch("icon_partial_path:#{name}:#{type}", expires_in: 15.minutes, &lookup)
79
+ end
68
80
  end
@@ -6,7 +6,6 @@
6
6
  %meta{ name: 'apple-mobile-web-app-capable', content: 'yes'}
7
7
  %meta{ name: 'apple-mobile-web-app-status-bar-style', content: 'black'}
8
8
  = stylesheet_link_tag 'https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css'
9
- = stylesheet_link_tag 'https://fonts.googleapis.com/icon?family=Material+Icons'
10
9
  %title="#{Rails.env} Status"
11
10
  %body{ style: 'background-color: #006064;'}
12
11
  %header
@@ -32,7 +31,6 @@
32
31
  %td
33
32
  %h4.flow-text=key.to_s.titleize
34
33
  %td.center
35
- %i.material-icons.medium{class: value[:icon_color]}
36
- = value[:icon_name]
34
+ = svg_icon(value[:icon_name], size: 32, color: value[:icon_color], cached: false)
37
35
  %td.center.hide-on-small-only
38
36
  %h4.flow-text.large=value[:message]
@@ -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.46'
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.46
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Schroeder