pub struct BrowserPoolConfig {
pub max_pool_size: usize,
pub warmup_count: usize,
pub ping_interval: Duration,
pub browser_ttl: Duration,
pub max_ping_failures: u32,
pub warmup_timeout: Duration,
}Expand description
Configuration for browser pool behavior and limits.
Controls pool size, browser lifecycle, and health monitoring parameters.
Use BrowserPoolConfigBuilder for validation and convenience.
§Fields Overview
| Field | Default | Description |
|---|---|---|
max_pool_size | 5 | Maximum browsers in pool |
warmup_count | 3 | Browsers to pre-create |
ping_interval | 15s | Health check frequency |
browser_ttl | 1 hour | Browser lifetime |
max_ping_failures | 3 | Failures before removal |
warmup_timeout | 60s | Warmup time limit |
§Example
use html2pdf_api::BrowserPoolConfig;
// Use defaults
let config = BrowserPoolConfig::default();
assert_eq!(config.max_pool_size, 5);Fields§
§max_pool_size: usizeMaximum number of browsers to keep in the pool (idle + active).
This is a soft limit - active browsers may temporarily exceed this during high load.
§Default
5 browsers
§Considerations
- Higher values = more memory usage, better concurrency
- Lower values = less memory, potential queuing under load
warmup_count: usizeNumber of browsers to pre-create during warmup phase.
Must be d max_pool_size. Reduces first-request latency.
§Default
3 browsers
§Considerations
- Set to
max_pool_sizefor fastest first requests - Set to 0 for lazy initialization (browsers created on demand)
ping_interval: DurationInterval between health check pings for active browsers.
Shorter intervals = faster failure detection, higher overhead.
§Default
15 seconds
§Considerations
- Too short: Unnecessary CPU/memory overhead
- Too long: Slow detection of crashed browsers
browser_ttl: DurationTime-to-live for each browser instance before forced retirement.
Prevents memory leaks from long-running browser processes.
§Default
1 hour (3600 seconds)
§Considerations
- Chrome can accumulate memory over time
- Shorter TTL = more browser restarts, fresher instances
- Longer TTL = fewer restarts, potential memory growth
max_ping_failures: u32Maximum consecutive ping failures before removing a browser.
Higher values = more tolerance for transient failures.
§Default
3 consecutive failures
§Considerations
- Set to 1 for aggressive failure detection
- Set higher if experiencing transient network issues
warmup_timeout: DurationMaximum time allowed for warmup process to complete.
If warmup doesn’t complete in this time, it fails with timeout error.
§Default
60 seconds
§Considerations
- Should be at least
warmup_count * ~5 secondsper browser - Increase if running on slow hardware or with many warmup browsers
Trait Implementations§
Source§impl Clone for BrowserPoolConfig
impl Clone for BrowserPoolConfig
Source§fn clone(&self) -> BrowserPoolConfig
fn clone(&self) -> BrowserPoolConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BrowserPoolConfig
impl Debug for BrowserPoolConfig
Source§impl Default for BrowserPoolConfig
impl Default for BrowserPoolConfig
Source§fn default() -> Self
fn default() -> Self
Production-ready default configuration.
- Pool size: 5 browsers
- Warmup: 3 browsers
- Health checks: Every 15 seconds
- TTL: 1 hour
- Failure tolerance: 3 consecutive failures
- Warmup timeout: 60 seconds
§Example
use html2pdf_api::BrowserPoolConfig;
use std::time::Duration;
let config = BrowserPoolConfig::default();
assert_eq!(config.max_pool_size, 5);
assert_eq!(config.warmup_count, 3);
assert_eq!(config.ping_interval, Duration::from_secs(15));
assert_eq!(config.browser_ttl, Duration::from_secs(3600));
assert_eq!(config.max_ping_failures, 3);
assert_eq!(config.warmup_timeout, Duration::from_secs(60));Auto Trait Implementations§
impl Freeze for BrowserPoolConfig
impl RefUnwindSafe for BrowserPoolConfig
impl Send for BrowserPoolConfig
impl Sync for BrowserPoolConfig
impl Unpin for BrowserPoolConfig
impl UnwindSafe for BrowserPoolConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoCollection<T> for T
impl<T> IntoCollection<T> for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);