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
impl ResultStash
Sourcepub fn new(stash_dir: PathBuf, config: StashConfig) -> Result<Self>
pub fn new(stash_dir: PathBuf, config: StashConfig) -> Result<Self>
Create a new stash rooted at stash_dir. Creates the directory if
missing.
Sourcepub fn config(&self) -> &StashConfig
pub fn config(&self) -> &StashConfig
Return the stash configuration.
Sourcepub fn insert_bytes(
&self,
task_id: i32,
result_name: String,
format: StashFormat,
data: Vec<u8>,
) -> Result<String>
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.
Sourcepub fn insert_file(
&self,
task_id: i32,
result_name: String,
format: StashFormat,
path: PathBuf,
) -> Result<String>
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.
Sourcepub fn take(&self, handle: &str) -> Option<StashEntry>
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.
Sourcepub fn peek_size(&self, handle: &str) -> Option<u64>
pub fn peek_size(&self, handle: &str) -> Option<u64>
Return size_bytes for handle without removing the entry.
Sourcepub fn cleanup_after_pull(&self, entry: &StashEntry)
pub fn cleanup_after_pull(&self, entry: &StashEntry)
Delete the SDK-written temp file for a pulled entry. No-op for plugin-owned files.
Sourcepub fn sweep_task(&self, task_id: i32) -> usize
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.
Sourcepub fn sweep_expired(&self) -> usize
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.
fn sweep_where(&self, predicate: impl Fn(&StashEntry) -> bool) -> usize
Sourcepub fn sweep_orphans_on_startup(stash_dir: &Path) -> Result<usize>
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§
impl !Freeze for ResultStash
impl RefUnwindSafe for ResultStash
impl Send for ResultStash
impl Sync for ResultStash
impl Unpin for ResultStash
impl UnsafeUnpin for ResultStash
impl UnwindSafe for ResultStash
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].