usps-support 0.2.53 → 0.2.55

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: 6ec8ac34f7499390a693ef659146f5eb3daa6b49da02852174256d6cd39ec62a
4
- data.tar.gz: dd4b7baa3db26305c0e9637140db783d8bdcb79e6080f3928fa60adf80e465a0
3
+ metadata.gz: 2c0cf433c2d144a8f87a14bd3dcb7dea7715d0f567a2373ae94995d8f6bebf24
4
+ data.tar.gz: a219ef3451fd7afa40ece594f54119ea29923d981f53ce84b3213b7d0c1419d8
5
5
  SHA512:
6
- metadata.gz: e88a8e2cc206895e6c2884c74f9a9ee038a4cf176eadbfb96c257f4871daf6fd11eb1dd96fc1e5b39879e433ee01a6fd1cfc213887524f8f39926dd33bfd26ec
7
- data.tar.gz: f2b45c152f44e96a57821a02afbf7987401e33de96553ac36a1b7ef3b2e0999fe0b5ef970b0b9382a1bc0aecd8ba90ac11bf7e760d71d85ed25b177b919f4be3
6
+ metadata.gz: 52e39a4662db847d220472723875c1bb9f45eb97f01e8484969703e6ae946dee9872063186bf2d37b2fd400a3efdc594f4b2d77409eac38046ef63264f71d685
7
+ data.tar.gz: a6a4fad3524230632c11f668dd5b190b21f9010bb5ad7579cc7e295222bdd4b86679a5016328143c9801bf907063f57f6b03b0d7d9800d9740298886cc7121ed
@@ -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.
@@ -74,7 +74,7 @@ ActiveRecord::Schema[8.1].define do
74
74
  t.index ["sqnumber"], name: "csq_index"
75
75
  end
76
76
 
77
- create_table "students", id: :integer, charset: "latin1", comment: "dtb-Active eddept HQ800 students", options: "ENGINE=MyISAM", force: :cascade do |t|
77
+ create_table "students", id: :integer, charset: "latin1", comment: "dtb-Active eddept HQ800 students", options: "ENGINE=InnoDB", force: :cascade do |t|
78
78
  t.string "csl", limit: 1
79
79
  t.string "crsid", limit: 17
80
80
  t.string "start", limit: 6
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Support
5
- VERSION = '0.2.53'
5
+ VERSION = '0.2.55'
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.53
4
+ version: 0.2.55
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander