Skip to main content

GlobalCache

Struct GlobalCache 

Source
pub struct GlobalCache { /* private fields */ }
Expand description

On-disk global cache for OCI layers and EROFS images.

Layout:

~/.microsandbox/cache/manifests/<sha256-of-ref>.json       # manifest + config metadata
~/.microsandbox/cache/tmp/<blob>.part                      # partial downloads
~/.microsandbox/cache/tmp/<blob>.download.lock             # download flock files
~/.microsandbox/cache/tmp/<blob>.work/                     # materialization work dirs
~/.microsandbox/cache/layers/<diff_id_safe>.erofs          # per-layer EROFS
~/.microsandbox/cache/layers/<diff_id_safe>.erofs.lock     # materialization flock
~/.microsandbox/cache/fsmeta/<manifest_safe>.erofs         # fsmeta EROFS (fsmerge metadata)
~/.microsandbox/cache/fsmeta/<manifest_safe>.erofs.lock    # materialization flock
~/.microsandbox/cache/vmdk/<manifest_safe>.vmdk            # VMDK descriptor
~/.microsandbox/cache/vmdk/<manifest_safe>.vmdk.lock       # materialization flock

Implementations§

Source§

impl GlobalCache

Source

pub fn operation(&self) -> Self

Start an operation scope. Its clones retain admitted entries until all clones are dropped. Keep this scope through publication of durable catalog ownership, including sandbox rows.

Source

pub fn lease_paths(&self, paths: Vec<PathBuf>) -> ImageResult<Vec<StorageLease>>

Protect entries in stable path order. The returned leases cover this call’s reader; an operation scope additionally retains them through its caller’s publication.

Source

pub async fn lease_paths_async( &self, paths: Vec<PathBuf>, ) -> ImageResult<Vec<StorageLease>>

Async counterpart of Self::lease_paths.

Source

pub fn metadata_paths( &self, metadata: &CachedImageMetadata, ) -> ImageResult<Vec<PathBuf>>

All independently reclaimable entries belonging to this immutable manifest.

Source§

impl GlobalCache

Source

pub fn new(cache_dir: &Path) -> ImageResult<Self>

Create a new GlobalCache using the provided cache directory.

Creates all subdirectories if they don’t exist.

Source

pub async fn new_async(cache_dir: &Path) -> ImageResult<Self>

Create a new GlobalCache using async filesystem operations.

Source

pub fn layers_dir(&self) -> &Path

Root layer EROFS cache directory.

Source

pub fn layer_erofs_path(&self, diff_id: &Digest) -> PathBuf

Path to the per-layer EROFS image for a given diff_id.

Source

pub fn layer_erofs_lock_path(&self, diff_id: &Digest) -> PathBuf

Path to the materialization lock for a layer EROFS image.

Source

pub fn is_layer_materialized(&self, diff_id: &Digest) -> bool

Check if a layer EROFS image exists.

Source

pub fn all_layers_materialized(&self, diff_ids: &[Digest]) -> bool

Check if all given layer diff_ids have materialized EROFS images.

Source

pub fn fsmeta_dir(&self) -> &Path

Root fsmeta EROFS cache directory.

Source

pub fn fsmeta_erofs_path(&self, manifest_digest: &Digest) -> PathBuf

Path to the fsmeta EROFS image for a given manifest digest.

Source

pub fn fsmeta_erofs_lock_path(&self, manifest_digest: &Digest) -> PathBuf

Path to the materialization lock for a fsmeta EROFS image.

Source

pub fn is_fsmeta_materialized(&self, manifest_digest: &Digest) -> bool

Check if a fsmeta EROFS image exists.

Source

pub fn vmdk_dir(&self) -> &Path

Root VMDK cache directory.

Source

pub fn vmdk_path(&self, manifest_digest: &Digest) -> PathBuf

Path to the VMDK descriptor for a given manifest digest.

Source

pub fn vmdk_lock_path(&self, manifest_digest: &Digest) -> PathBuf

Path to the materialization lock for a VMDK descriptor.

Source

pub fn is_vmdk_materialized(&self, manifest_digest: &Digest) -> bool

Check if a VMDK descriptor exists for a given manifest digest.

Source

pub fn rewrite_vmdk( &self, manifest_digest: &Digest, layer_diff_ids: &[Digest], ) -> ImageResult<()>

Rewrite the VMDK descriptor for a manifest digest so its extents are this cache’s fsmeta and layer EROFS files.

Descriptors reference extents by absolute path, so one copied from another cache must be regenerated rather than reused.

Source

pub fn flat_ref_path(&self, manifest_digest: &Digest) -> PathBuf

Path to the manifest-keyed flat rootfs reference.

Source

pub fn flat_blob_path(&self, artifact_digest: &Digest) -> PathBuf

Path to the immutable content-addressed raw ext4 artifact.

Source

pub fn flat_lock_path(&self, derivation_digest: &Digest) -> PathBuf

Path to the per-derivation flat materialization lock.

Source

pub fn flat_work_dir(&self, derivation_digest: &Digest) -> PathBuf

Same-filesystem work directory for one flat-rootfs derivation.

Source

pub fn publish_flat_blob( &self, candidate: &Path, artifact_digest: &Digest, expected_size: u64, ) -> ImageResult<PathBuf>

Publish a synchronized candidate as an immutable content-addressed blob.

Source

pub fn read_flat_ref( &self, manifest_digest: &Digest, ) -> ImageResult<Option<FlatRootfsRef>>

Read and validate the manifest-keyed flat rootfs reference.

Source

pub fn write_flat_ref( &self, manifest_digest: &Digest, reference: &FlatRootfsRef, ) -> ImageResult<()>

Atomically replace a flat rootfs reference after its immutable blob is durable.

Source

pub fn tmp_dir(&self) -> &Path

Root staging directory.

Source

pub fn part_path(&self, blob_digest: &Digest) -> PathBuf

Path to the partial download file for a blob.

Source

pub fn download_lock_path(&self, blob_digest: &Digest) -> PathBuf

Path to the download lock file for a blob.

Source

pub fn work_dir(&self, key: &Digest) -> PathBuf

Path to the materialization work directory for an EROFS build.

Source

pub fn manifests_dir(&self) -> &Path

Root manifest metadata directory.

Source

pub fn image_lock_path(&self, reference: &Reference) -> PathBuf

Path to the pull lock file for an image reference.

Source

pub fn read_image_metadata( &self, reference: &Reference, ) -> ImageResult<Option<CachedImageMetadata>>

Read cached metadata for an image reference.

Source

pub async fn read_image_metadata_async( &self, reference: &Reference, ) -> ImageResult<Option<CachedImageMetadata>>

Read and admit metadata without blocking the async executor on locks.

Source

pub async fn write_image_metadata_async( &self, reference: &Reference, metadata: &CachedImageMetadata, ) -> ImageResult<()>

Publish metadata from an owned worker so cancellation cannot release its gate while the filesystem replacement is still in flight.

Source

pub async fn install_image_metadata_if_compatible_async( &self, reference: &Reference, archived_bytes: Vec<u8>, ) -> ImageResult<()>

Install archived metadata without replacing an equivalent local entry. Recheck under the same publication gate used by image pulls, so a concurrent retag cannot be lost.

Source

pub fn delete_image_metadata(&self, reference: &Reference) -> ImageResult<()>

Delete cached metadata for an image reference.

Source

pub async fn delete_image_metadata_async( &self, reference: &Reference, ) -> ImageResult<()>

Delete cached metadata for an image reference using async filesystem I/O.

Source

pub fn image_metadata_path(&self, reference: &Reference) -> PathBuf

Path to the cached metadata file for an image reference.

Source

pub fn tar_path(&self, digest: &Digest) -> PathBuf

Path to the cached compressed tarball for a layer blob.

Trait Implementations§

Source§

impl Clone for GlobalCache

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more