Generic resource pool for browser engines. Each driver supplies a
Wallabidi.Driver.Pool callback module; the pool manages N slots
using those callbacks.
Test sessions check out a slot for the duration of their work and check it back in when done. The pool monitors checkout callers and auto-checks-in if a caller dies.
Configuration
config :wallabidi,
chrome: [pool_size: 4]Or pass at start_link time:
Wallabidi.Pool.start_link(
name: MyPool,
impl: Wallabidi.Chrome.Pool.Impl,
size: 4,
opts: [headless: true]
)Slot reuse
After a session ends, the slot is reset (reset_slot/1) and
returned to the available queue. If reset returns :must_recreate,
the pool tears down (close_slot/1) and reopens (open_slot/1)
the slot before making it available again.
Summary
Functions
Return a slot to the pool. Runs finalize_session/2 then makes
the slot available to the next checkout.
Check out a slot. Blocks until one is available. Returns
{:ok, slot_id, slot_handle, session_state}.
Returns a specification to start this module under a supervisor.
Functions
@spec checkin(GenServer.server(), non_neg_integer(), term()) :: :ok
Return a slot to the pool. Runs finalize_session/2 then makes
the slot available to the next checkout.
@spec checkout(GenServer.server(), keyword(), timeout()) :: {:ok, non_neg_integer(), term(), term()} | {:error, term()}
Check out a slot. Blocks until one is available. Returns
{:ok, slot_id, slot_handle, session_state}.
The caller is monitored — if it dies before checking back in, the
pool runs finalize_session/2 and returns the slot to the pool.
Returns a specification to start this module under a supervisor.
See Supervisor.