pub struct SessionPool { /* private fields */ }Expand description
A bounded collection of reusable crawler sessions.
use millipede_core::session::{SessionPool, SessionPoolOptions};
let pool = SessionPool::new(SessionPoolOptions::default());Implementations§
Source§impl SessionPool
impl SessionPool
Sourcepub fn new(options: SessionPoolOptions) -> Self
pub fn new(options: SessionPoolOptions) -> Self
Creates an empty pool. Persistence can be attached once storage opens.
Sourcepub fn attach_persistence(&self, kvs: Arc<dyn KeyValueStore>)
pub fn attach_persistence(&self, kvs: Arc<dyn KeyValueStore>)
Attaches the key-value store used by Self::persist and Self::restore.
Sourcepub async fn session(&self, sticky: Option<&SessionId>) -> Arc<Session>
pub async fn session(&self, sticky: Option<&SessionId>) -> Arc<Session>
Checks out a sticky usable session, creates one while below capacity, or rotates at random.
Sourcepub async fn retire_session(&self, id: &SessionId)
pub async fn retire_session(&self, id: &SessionId)
Retires the session with id when it exists.
Sourcepub async fn session_count(&self) -> usize
pub async fn session_count(&self) -> usize
Returns the number of currently retained entries.
Sourcepub async fn persist(&self) -> Result<(), CrawlError>
pub async fn persist(&self) -> Result<(), CrawlError>
Persists IDs, cookies, scores, usage, retirement, and original expiry.
Sourcepub async fn restore(&self) -> Result<(), CrawlError>
pub async fn restore(&self) -> Result<(), CrawlError>
Replaces pool contents from persisted state, skipping entries with corrupt cookie JSON.
Auto Trait Implementations§
impl !Freeze for SessionPool
impl !RefUnwindSafe for SessionPool
impl !UnwindSafe for SessionPool
impl Send for SessionPool
impl Sync for SessionPool
impl Unpin for SessionPool
impl UnsafeUnpin for SessionPool
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