Class: Flaky::Middleware::SimulateCiLatency
- Inherits:
-
Object
- Object
- Flaky::Middleware::SimulateCiLatency
- Defined in:
- lib/flaky/middleware/simulate_ci_latency.rb
Constant Summary collapse
- DEFAULT_DELAY_MS =
f1-standard-2: 2 vCPU, 4 GB RAM (shared tenant) Local Mac: 10+ cores, 16-64 GB RAM (dedicated) Empirically, CI system tests take ~2x longer than local. A 30ms delay per request approximates the difference.
30
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, delay_ms: nil) ⇒ SimulateCiLatency
constructor
A new instance of SimulateCiLatency.
Constructor Details
#initialize(app, delay_ms: nil) ⇒ SimulateCiLatency
Returns a new instance of SimulateCiLatency.
12 13 14 15 |
# File 'lib/flaky/middleware/simulate_ci_latency.rb', line 12 def initialize(app, delay_ms: nil) @app = app @delay_ms = (delay_ms || ENV.fetch("FLAKY_LATENCY_MS", DEFAULT_DELAY_MS)).to_f end |
Instance Method Details
#call(env) ⇒ Object
17 18 19 20 |
# File 'lib/flaky/middleware/simulate_ci_latency.rb', line 17 def call(env) sleep(@delay_ms / 1000.0) if @delay_ms > 0 @app.call(env) end |