Skip to main content

ResultStash

Struct ResultStash 

Source
pub struct ResultStash {
    stash_dir: PathBuf,
    config: StashConfig,
    entries: Mutex<HashMap<String, StashEntry>>,
}
Expand description

Disk-backed result stash.

Fields§

§stash_dir: PathBuf§config: StashConfig§entries: Mutex<HashMap<String, StashEntry>>

Implementations§

Source§

impl ResultStash

Source

pub fn new(stash_dir: PathBuf, config: StashConfig) -> Result<Self>

Create a new stash rooted at stash_dir. Creates the directory if missing.

Source

pub fn config(&self) -> &StashConfig

Return the stash configuration.

Source

pub fn insert_bytes( &self, task_id: i32, result_name: String, format: StashFormat, data: Vec<u8>, ) -> Result<String>

Insert an in-memory payload. Writes it to a new temp file in the stash directory and returns the handle.

Source

pub fn insert_file( &self, task_id: i32, result_name: String, format: StashFormat, path: PathBuf, ) -> Result<String>

Insert a reference to an existing file (plugin-owned). The file is not copied or touched, and is never deleted by the stash.

Source

pub fn take(&self, handle: &str) -> Option<StashEntry>

Take the entry for handle, removing it from the map.

The returned entry’s file has not been deleted - the caller (typically on_pull_result) reads it, then calls Self::cleanup_after_pull to delete SDK-owned files.

Source

pub fn peek_size(&self, handle: &str) -> Option<u64>

Return size_bytes for handle without removing the entry.

Source

pub fn cleanup_after_pull(&self, entry: &StashEntry)

Delete the SDK-written temp file for a pulled entry. No-op for plugin-owned files.

Source

pub fn sweep_task(&self, task_id: i32) -> usize

Remove all entries for a finished task. SDK-owned files are deleted; plugin-owned files are left alone. Returns the number of entries reclaimed.

Source

pub fn sweep_expired(&self) -> usize

Remove entries older than self.config.ttl. SDK-owned files deleted; plugin-owned files left alone. Returns the number of entries reclaimed.

Source

fn sweep_where(&self, predicate: impl Fn(&StashEntry) -> bool) -> usize

Source

pub fn sweep_orphans_on_startup(stash_dir: &Path) -> Result<usize>

Sweep any files in stash_dir that are not tracked in entries. Called once on startup to clean up orphans from a previous crashed run. Does not touch files referenced by live entries (which is always empty on startup).

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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.

§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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