pub struct BrowserSelector { /* private fields */ }Expand description
Picks the next browser in rotation based on per-domain failure history.
Follows the server’s hints.rs logic:
- Try current browser until
ROTATE_AFTER_FAILURESconsecutive failures. - Then move to the next browser in
BROWSER_ROTATIONorder. - Skip browsers that have also exceeded the failure threshold.
Implementations§
Source§impl BrowserSelector
impl BrowserSelector
Sourcepub fn new(tracker: FailureTracker) -> Self
pub fn new(tracker: FailureTracker) -> Self
Create a new selector backed by the given failure tracker.
Sourcepub fn failure_tracker(&self) -> &FailureTracker
pub fn failure_tracker(&self) -> &FailureTracker
Borrow the underlying failure tracker.
Sourcepub fn should_rotate(&self, domain: &str, current_browser: &str) -> bool
pub fn should_rotate(&self, domain: &str, current_browser: &str) -> bool
Check if the current browser should be rotated for a domain.
Returns true when the failure count for (domain, current_browser)
meets or exceeds ROTATE_AFTER_FAILURES.
Sourcepub fn next_browser(
&self,
domain: &str,
current_browser: &str,
) -> Option<&'static str>
pub fn next_browser( &self, domain: &str, current_browser: &str, ) -> Option<&'static str>
Pick the next browser to try after current_browser has failed.
Walks BROWSER_ROTATION starting from the position after
current_browser, wrapping around, and returns the first candidate
that has not exceeded the failure threshold for domain.
Returns None if every browser in the rotation has been exhausted.
Sourcepub fn choose_browser<'a>(&self, domain: &str, fallback: &'a str) -> &'a strwhere
'static: 'a,
pub fn choose_browser<'a>(&self, domain: &str, fallback: &'a str) -> &'a strwhere
'static: 'a,
Choose the best browser for a domain (mirrors hints.rs choose_browser_for_domain).
Returns the first browser in BROWSER_ROTATION that has not
exceeded the failure threshold. Falls back to fallback if every
browser is exhausted.