pub struct BrowserPool { /* private fields */ }Expand description
Thread-safe pool of reusable BrowserInstances.
Maintains a warm set of idle browsers ready for immediate acquisition
(<100ms), and lazily launches new instances when demand spikes.
§Example
use stygian_browser::{BrowserConfig, BrowserPool};
let pool = BrowserPool::new(BrowserConfig::default()).await?;
let handle = pool.acquire().await?;
handle.release().await;Implementations§
Source§impl BrowserPool
impl BrowserPool
Sourcepub async fn new(config: BrowserConfig) -> Result<Arc<Self>>
pub async fn new(config: BrowserConfig) -> Result<Arc<Self>>
Create a new pool and pre-warm config.pool.min_size browser instances.
Warmup failures are logged but not fatal — the pool will start smaller and grow lazily.
§Example
use stygian_browser::{BrowserPool, BrowserConfig};
let pool = BrowserPool::new(BrowserConfig::default()).await?;Sourcepub async fn acquire(self: &Arc<Self>) -> Result<BrowserHandle>
pub async fn acquire(self: &Arc<Self>) -> Result<BrowserHandle>
Acquire a browser handle from the pool.
- If a healthy idle browser is available it is returned immediately.
- If
active < max_sizea new browser is launched. - Otherwise waits up to
pool.acquire_timeout.
§Errors
Returns BrowserError::PoolExhausted if no browser becomes available
within pool.acquire_timeout.
§Example
use stygian_browser::{BrowserPool, BrowserConfig};
let pool = BrowserPool::new(BrowserConfig::default()).await?;
let handle = pool.acquire().await?;
handle.release().await;Auto Trait Implementations§
impl Freeze for BrowserPool
impl !RefUnwindSafe for BrowserPool
impl Send for BrowserPool
impl Sync for BrowserPool
impl Unpin for BrowserPool
impl UnsafeUnpin for BrowserPool
impl !UnwindSafe for BrowserPool
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
Mutably borrows from an owned value. Read more