usps-support 0.2.54 → 0.2.56

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: 25e1fba8f54fb60dbbfb9a732b97e778870360e9364793f360f843209c494637
4
- data.tar.gz: 439cdf0bf9b9732ad9c3121937b5b4ea2f937b03bf08f12fc9715bb565a43857
3
+ metadata.gz: 62e9af5356bcd1225e25c991b17f12adfe1aba9966c46fab7c0c579369da84dd
4
+ data.tar.gz: 40296e55d69d18fdef651c805ff126d39e6ba00d9eabaf88dafddc2f8390f2a9
5
5
  SHA512:
6
- metadata.gz: aad1a023c1b15d3576d07d55d80bc61f6b97c8d0c1f2f845476458e8f8f2bb2d5ef7ce15bea1187d98db900fae9fd7fdbca9e884f4b513f602c60f0a158ab909
7
- data.tar.gz: c292fde711fece0d25b67b0616fcfe37a2a88dd65277693afb70d7f4ad795dea84d455b2e4257e00d796a86bfa478c9ea901c7dca9e17bcc8a4a33bed0a2dc12
6
+ metadata.gz: 33e56e8f63917e3fc353ff5f45d6517696e04e427def8bed96035f263a1e5530d666e6e97ad82930bf2716ab91d89bc76e99ae1c5cfb29ba695098e4617b58d8
7
+ data.tar.gz: 3c53c7c5d9e0a021b30b660d1663c1fa5b7722360f1ea89f04dbfbd6bd1cc09cadb30da31916b8ab9b629b76bc56c1ade9f8aeb2a5c8909c3a9b372a038e4d2a
@@ -20,6 +20,11 @@ module Usps::Support
20
20
  # and route to it (`get 'health' => 'health#show'`). For a bespoke dependency, define a
21
21
  # #check_<name> in the subclass (e.g. wrapping #check_http(url)) and add <name> to CHECKS.
22
22
  #
23
+ # Responds 503 when any check fails, EXCEPT to callers that pass ?probe=1, which always get 200
24
+ # and are expected to judge health by the sentinel in the body. That exists so a failing
25
+ # dependency does not register as an application 5XX on the load balancer -- see #response_status.
26
+ # Point external string-matching probes at /health?probe=1; leave it off everywhere else.
27
+ #
23
28
  # Checks run on a background thread, not the request thread: a per-process refresher updates a
24
29
  # cached snapshot every health_refresh_interval seconds and #show serves that snapshot, so a slow
25
30
  # or wedged dependency can't tie up the Passenger worker pool. Each check also runs under
@@ -124,7 +129,7 @@ module Usps::Support
124
129
 
125
130
  response.set_header('Cache-Control', 'no-store')
126
131
  response.set_header('Retry-After', '30') unless healthy
127
- render(plain: body, content_type: 'text/plain', status: healthy ? :ok : :service_unavailable)
132
+ render(plain: body, content_type: 'text/plain', status: response_status(healthy))
128
133
  end
129
134
 
130
135
  # Fallback for the (rare) case where not even the first refresh could produce a snapshot.
@@ -132,9 +137,26 @@ module Usps::Support
132
137
  response.set_header('Cache-Control', 'no-store')
133
138
  response.set_header('Retry-After', '30')
134
139
  render(plain: "HEALTHCHECK_FAIL #{app_name}\nsnapshot=unavailable\n",
135
- content_type: 'text/plain', status: :service_unavailable)
140
+ content_type: 'text/plain', status: response_status(false))
136
141
  end
137
142
 
143
+ # True when the caller asked to be judged on the body alone (?probe=1).
144
+ def probe_mode? = params[:probe].present?
145
+
146
+ # A Route 53 HTTPS_STR_MATCH probe decides health by matching the sentinel in the body, so for it
147
+ # the status code says nothing the body has not already said. That redundancy is not free: the
148
+ # ALB counts a 503 on this path as an application 5XX, landing it in HTTPCode_Target_5XX_Count
149
+ # next to genuine user-facing errors. A slow dependency then pages on an endpoint no user ever
150
+ # touched (2026-08-05: 155 such 5XX across exams and merit-marks, all of them this endpoint
151
+ # answering the Route 53 checker, none of them a real request).
152
+ #
153
+ # Probe-mode callers therefore get 200 with the identical body -- still HEALTHCHECK_FAIL, still
154
+ # every per-check line, so the probe goes red exactly as before. Everyone else keeps the
155
+ # status-coded contract, which is what a human curl or a status-code-driven monitor expects.
156
+ # A crashed app or dead worker still yields the web server's own 5xx with no sentinel, so total
157
+ # failure remains detectable either way.
158
+ def response_status(healthy) = healthy || probe_mode? ? :ok : :service_unavailable
159
+
138
160
  # One round of checks + diagnostics, invoked by the monitor's runner (background thread, or the
139
161
  # inline cold/stale path). Wrapped in the Rails executor so ActiveRecord connections checked out
140
162
  # by the DB checks are returned even though this runs outside a request. Returns the render data.
@@ -36,18 +36,16 @@ ActiveRecord::Schema[8.1].define do
36
36
  t.string "died", limit: 8
37
37
  end
38
38
 
39
- create_table "djdesc", primary_key: "jobcode", id: { type: :string, limit: 5 }, charset: "latin1", comment: "dtb-created daily has active dist Job descritpions", force: :cascade do |t|
39
+ create_table "djdesc", primary_key: "jobcode", id: { type: :string, limit: 7 }, charset: "latin1", comment: "dtb-created daily has active dist Job descritpions", force: :cascade do |t|
40
40
  t.string "jdesc", limit: 100
41
41
  t.string "rank", limit: 3, null: false
42
42
  t.string "prank", limit: 3, null: false
43
- t.string "OD1", limit: 1, null: false
44
- t.string "OD2", limit: 1, null: false
45
- t.string "ED1", limit: 1, null: false
43
+ t.string "type", limit: 1, null: false
44
+ t.string "active", limit: 1, null: false
45
+ t.string "admin", limit: 5, null: false
46
+ t.string "map", limit: 1, null: false
46
47
  t.string "Lev", limit: 1, null: false
47
- t.string "EGA", limit: 1, null: false
48
48
  t.string "Descript", limit: 7, null: false
49
- t.string "OP", limit: 1
50
- t.string "Sp", limit: 1
51
49
  end
52
50
 
53
51
  create_table "djftp", id: false, charset: "latin1", comment: "dtb - Current District Jobs loaded from HQ data", force: :cascade do |t|
@@ -170,18 +168,16 @@ ActiveRecord::Schema[8.1].define do
170
168
  t.string "RankAbbr", limit: 15
171
169
  end
172
170
 
173
- create_table "sjdesc", primary_key: "jobcode", id: { type: :string, limit: 5 }, charset: "latin1", comment: "dtb-created daily has active squad Job descritpions", force: :cascade do |t|
171
+ create_table "sjdesc", primary_key: "jobcode", id: { type: :string, limit: 7 }, charset: "latin1", comment: "dtb-created daily has active squad Job descritpions", force: :cascade do |t|
174
172
  t.string "jdesc", limit: 100
175
173
  t.string "rank", limit: 3, null: false
176
174
  t.string "prank", limit: 3, null: false
177
- t.string "OD1", limit: 1, null: false
178
- t.string "OD2", limit: 1, null: false
179
- t.string "ED1", limit: 1, null: false
175
+ t.string "type", limit: 1, null: false
176
+ t.string "active", limit: 1, null: false
177
+ t.string "admin", limit: 5, null: false
178
+ t.string "map", limit: 1, null: false
180
179
  t.string "Lev", limit: 1, null: false
181
- t.string "EGA", limit: 1, null: false
182
180
  t.string "Descript", limit: 7, null: false
183
- t.string "OP", limit: 1
184
- t.string "Sp", limit: 1
185
181
  end
186
182
 
187
183
  create_table "sjftp", id: false, charset: "latin1", comment: "dtb-created daily from HQ active squadron jobs", force: :cascade do |t|
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Support
5
- VERSION = '0.2.54'
5
+ VERSION = '0.2.56'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usps-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.54
4
+ version: 0.2.56
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander