pub struct MultipartStateStore { /* private fields */ }Expand description
In-memory side-table mapping upload_id → context. One of these
hangs off S4Service (always-on, no flag — the per-upload state is
gateway-internal).
Implementations§
Source§impl MultipartStateStore
impl MultipartStateStore
Sourcepub fn new() -> Self
pub fn new() -> Self
Empty store. Use Arc<MultipartStateStore> so S4Service’s
async handlers can borrow it across &self calls without
requiring Clone.
Sourcepub fn put(&self, upload_id: &str, ctx: MultipartUploadContext)
pub fn put(&self, upload_id: &str, ctx: MultipartUploadContext)
Register a new upload under upload_id. If upload_id is
already present (extremely unlikely — backend issues fresh ids)
the previous entry is overwritten silently to mirror
HashMap::insert’s replace-on-collision semantics.
Sourcepub fn get(&self, upload_id: &str) -> Option<MultipartUploadContext>
pub fn get(&self, upload_id: &str) -> Option<MultipartUploadContext>
Snapshot the context for upload_id. None when no entry was
registered (e.g. Complete arrived for an upload that the gateway
has no record of — passes through to the backend untouched, which
in turn surfaces NoSuchUpload).
Sourcepub fn remove(&self, upload_id: &str)
pub fn remove(&self, upload_id: &str)
Drop the entry. Called by Complete / Abort to release the SSE-C key bytes and the tag-set memory promptly.
Sourcepub fn completion_lock(&self, bucket: &str, key: &str) -> Arc<Mutex<()>> ⓘ
pub fn completion_lock(&self, bucket: &str, key: &str) -> Arc<Mutex<()>> ⓘ
v0.8.1 #59: get-or-create the per-(bucket, key) Mutex used to
serialise complete_multipart_upload invocations on the same
logical key. Caller does lock.lock().await and holds the
guard for the duration of its critical section (GET assembled
body → encrypt → PUT encrypted body → version-id mint → object-
lock apply → tagging persist → replication enqueue).
Returns an Arc<Mutex<()>> so the caller can drop the
DashMap shard’s read lock immediately and only retain the
mutex itself across the await point — DashMap’s shard guard
is !Send, so we must not hold it through an await.
Sourcepub fn prune_completion_locks(&self)
pub fn prune_completion_locks(&self)
v0.8.1 #59: best-effort cleanup of stale completion-lock
entries. A (bucket, key) entry is “stale” once no concurrent
Complete is referencing its Arc<Mutex<()>> — we detect that
by Arc::strong_count == 1 (only the DashMap itself holds a
reference). Called from complete_multipart_upload after the
guarded section returns, so a steady-state workload of unique
keys never accumulates locks.
The retain predicate is > 1 (keep entries with outstanding
borrowers), so prune is safe to invoke concurrently with other
completion_lock callers — at worst the prune sees the entry
during a brief window where the borrower has cloned but not yet
taken lock(), and the entry survives until the next sweep.