Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions pkgs/id/crates/id-store/src/admission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,20 @@ impl FollowUpSink {
pub fn request(&self, operation_id: OperationId, envelope: Envelope) {
self.queued
.lock()
.expect("follow-up sink poisoned")
.unwrap_or_else(|poisoned| poisoned.into_inner())
.push(QueuedOperation {
operation_id,
envelope,
});
}

fn drain(&self) -> Vec<QueuedOperation> {
std::mem::take(&mut *self.queued.lock().expect("follow-up sink poisoned"))
std::mem::take(
&mut *self
.queued
.lock()
.unwrap_or_else(|poisoned| poisoned.into_inner()),
)
}
}

Expand Down Expand Up @@ -438,15 +443,15 @@ impl OperationLedger for MemoryOperationLedger {
fn entry(&self, operation_id: &OperationId) -> Option<LedgerEntry> {
self.entries
.lock()
.expect("operation ledger poisoned")
.unwrap_or_else(|poisoned| poisoned.into_inner())
.get(operation_id)
.cloned()
}

fn record(&self, operation_id: OperationId, entry: LedgerEntry) {
self.entries
.lock()
.expect("operation ledger poisoned")
.unwrap_or_else(|poisoned| poisoned.into_inner())
.insert(operation_id, entry);
}
}
Expand Down Expand Up @@ -500,14 +505,14 @@ impl OutboxJournal for MemoryOutboxJournal {
let key = (pending.event_id.clone(), pending.hook_id.clone());
self.pending
.lock()
.expect("outbox journal poisoned")
.unwrap_or_else(|poisoned| poisoned.into_inner())
.insert(key, pending);
}

fn pending(&self) -> Vec<PendingDelivery> {
self.pending
.lock()
.expect("outbox journal poisoned")
.unwrap_or_else(|poisoned| poisoned.into_inner())
.values()
.cloned()
.collect()
Expand All @@ -516,7 +521,7 @@ impl OutboxJournal for MemoryOutboxJournal {
fn clear(&self, event_id: &str, hook_id: &HookId) {
self.pending
.lock()
.expect("outbox journal poisoned")
.unwrap_or_else(|poisoned| poisoned.into_inner())
.remove(&(event_id.to_owned(), hook_id.clone()));
}
}
Expand Down Expand Up @@ -695,7 +700,7 @@ impl Drop for InFlightGuard<'_> {
fn drop(&mut self) {
self.set
.lock()
.expect("in-flight set poisoned")
.unwrap_or_else(|poisoned| poisoned.into_inner())
.remove(&self.operation_id);
}
}
Expand Down Expand Up @@ -781,7 +786,10 @@ impl AdmissionPipeline {
commit: impl FnOnce(&CommitInput<'_>) -> Result<(), String>,
) -> Result<PipelineOutcome, LifecycleRejection> {
{
let mut in_flight = self.in_flight.lock().expect("in-flight set poisoned");
let mut in_flight = self
.in_flight
.lock()
.unwrap_or_else(|poisoned| poisoned.into_inner());
if !in_flight.insert(operation_id.clone()) {
return Err(LifecycleRejection::ReentrantOperation { operation_id });
}
Expand Down