Class: Heatwave::Crawler::Tiers::Playwright
- Inherits:
-
Object
- Object
- Heatwave::Crawler::Tiers::Playwright
- Defined in:
- app/services/heatwave/crawler/tiers/playwright.rb,
app/services/heatwave/crawler/tiers/playwright/limiter.rb
Overview
Tier: full page load in headless Chromium via PlaywrightRuntime
(the always-on Kamal accessory in staging/production, local driver in
development). Captures the rendered DOM plus technical artifacts —
console errors, failed requests, redirect chain, response headers,
optional screenshot — which powers :inspect mode and the free middle
rung of :auto escalation (per-request cost is zero; capacity is the
constraint, guarded by Limiter).
Defined Under Namespace
Classes: Limiter
Constant Summary collapse
- NAVIGATION_TIMEOUT_MS =
30_000- SETTLE_TIMEOUT_MS =
5_000- ARTIFACT_LIMIT =
50
Instance Method Summary collapse
-
#applies_to?(_url) ⇒ Boolean
Browsers must never launch in the test env — tier tests stub the whole tier (same spirit as Retailer::DailyCostGuard.disabled?).
- #attempt(url) ⇒ Heatwave::Crawler::FetchOutcome
-
#initialize(policy) ⇒ Playwright
constructor
A new instance of Playwright.
Constructor Details
#initialize(policy) ⇒ Playwright
Returns a new instance of Playwright.
18 19 20 |
# File 'app/services/heatwave/crawler/tiers/playwright.rb', line 18 def initialize(policy) @policy = policy end |
Instance Method Details
#applies_to?(_url) ⇒ Boolean
Browsers must never launch in the test env — tier tests stub the
whole tier (same spirit as Retailer::DailyCostGuard.disabled?).
24 25 26 |
# File 'app/services/heatwave/crawler/tiers/playwright.rb', line 24 def applies_to?(_url) !Rails.env.test? end |
#attempt(url) ⇒ Heatwave::Crawler::FetchOutcome
30 31 32 33 34 35 36 |
# File 'app/services/heatwave/crawler/tiers/playwright.rb', line 30 def attempt(url) rendered = Limiter.with_slot { render(url) } rendered || Tiers.error_outcome(tier: :playwright, url: url, error: 'render capacity unavailable') rescue StandardError => e Tiers.error_outcome(tier: :playwright, url: url, error: e, exception: e) end |