pub struct PullStore { /* private fields */ }Expand description
The directory of pull jobs.
Implementations§
Source§impl PullStore
impl PullStore
Sourcepub fn new(root: impl Into<PathBuf>) -> Self
pub fn new(root: impl Into<PathBuf>) -> Self
A store over root, which is created when the first job is.
Sourcepub fn create(
&self,
plan: &InstallPlan,
now: i64,
) -> Result<PullJobDir, PullError>
pub fn create( &self, plan: &InstallPlan, now: i64, ) -> Result<PullJobDir, PullError>
Create a job for plan at now, claiming its directory and writing the
descriptor and a queued record.
Sourcepub fn list(&self) -> Vec<PullJobDir>
pub fn list(&self) -> Vec<PullJobDir>
Every readable job, oldest first. A directory without a readable
descriptor is not a job and is skipped; so is a store that cannot be
read at all, which PullStore::jobs reports instead of hiding.
Sourcepub fn jobs(&self) -> Result<Vec<PullJobDir>, PullError>
pub fn jobs(&self) -> Result<Vec<PullJobDir>, PullError>
Every readable job, oldest first, reporting a store that could not be read (a missing store is simply empty).
Sourcepub fn resolve(&self, query: &str) -> Result<PullJobDir, PullError>
pub fn resolve(&self, query: &str) -> Result<PullJobDir, PullError>
The one job query names: an exact id, then an unambiguous id prefix,
then an exact reference (ignoring case).
Sourcepub fn under_way(
&self,
provider: &InstallProviderId,
reference: &str,
now_ms: i64,
) -> Option<PullJobDir>
pub fn under_way( &self, provider: &InstallProviderId, reference: &str, now_ms: i64, ) -> Option<PullJobDir>
The newest job pulling reference from provider that a client could
join: one still going, or one that stopped with bytes worth resuming.
The reference is matched the way PullStore::resolve matches one, so a
tag the provider rewrote (ls into ls:latest) only joins the job it
created once the caller passes the rewritten form. A job whose worker
never arrived is past joining: nothing is coming for it, and preferring
it because it is newest would hide the pull that is actually running.
Sourcepub fn sweep(&self, keep: usize, before_ms: i64) -> usize
pub fn sweep(&self, keep: usize, before_ms: i64) -> usize
Remove ended jobs last touched before before_ms, keeping the newest
keep of them however old they are. Returns how many were removed.
Each goes through forget, so a job whose
worker still holds the lock is left, however its record reads.