use super::{CallTrace, EntryState, Instant, PendingReplyTable};
impl PendingReplyTable {
pub(in crate::server::connection) fn dispatched(&mut self, op_id: u64, at: Instant) {
if let Some(entry) = self.entries.iter_mut().find(|entry| entry.op_id == op_id) {
entry.dispatched_at = Some(at);
}
}
pub(in crate::server::connection) const fn next_operation(&self) -> u64 {
self.next_op_id
}
pub(in crate::server::connection) fn bind_tap(&mut self, op_id: u64, mut tap: CallTrace) {
if let Some(entry) = self
.entries
.iter_mut()
.find(|entry| entry.op_id == op_id && entry.state == EntryState::Pending)
{
if let Some(dispatched) = entry.dispatched_at {
tap.dispatched_at(dispatched);
}
entry.tap = Some(tap);
} else {
tap.finish(
crate::tap::TapOutcome::Refused,
Some("call_not_pending"),
Instant::now(),
);
}
}
pub(in crate::server::connection) fn refuse(&mut self, op_id: u64, reason: &str) {
if let Some(entry) = self.entries.iter_mut().find(|entry| entry.op_id == op_id)
&& let Some(tap) = entry.tap.take()
{
tap.finish(
crate::tap::TapOutcome::Refused,
Some(reason),
Instant::now(),
);
}
self.cancel(op_id);
}
}