MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / enqueue

Method enqueue

nodedb-crdt/src/dead_letter.rs:121–161  ·  view source on GitHub ↗
(
        &mut self,
        peer_id: u64,
        user_id: u64,
        tenant_id: u64,
        delta: Vec<u8>,
        constraint: &Constraint,
        reason: String,
        hint: CompensationHint

Source from the content-addressed store, hash-verified

119 /// Enqueue a rejected delta with full auth context.
120 #[allow(clippy::too_many_arguments)]
121 pub fn enqueue(
122 &mut self,
123 peer_id: u64,
124 user_id: u64,
125 tenant_id: u64,
126 delta: Vec<u8>,
127 constraint: &Constraint,
128 reason: String,
129 hint: CompensationHint,
130 ) -> Result<u64> {
131 if self.entries.len() >= self.capacity {
132 return Err(CrdtError::DlqFull {
133 capacity: self.capacity,
134 pending: self.entries.len(),
135 });
136 }
137
138 let id = self.next_id;
139 self.next_id += 1;
140
141 let now = SystemTime::now()
142 .duration_since(UNIX_EPOCH)
143 .unwrap_or_default()
144 .as_millis() as u64;
145
146 self.entries.push_back(DeadLetter {
147 id,
148 peer_id,
149 user_id,
150 tenant_id,
151 delta,
152 violated_constraint: constraint.name.clone(),
153 collection: constraint.collection.clone(),
154 reason,
155 hint,
156 rejected_at: now,
157 retry_count: 0,
158 });
159
160 Ok(id)
161 }
162
163 /// Peek at the oldest dead letter without removing it.
164 pub fn peek(&self) -> Option<&DeadLetter> {

Callers 5

enqueue_and_dequeueFunction · 0.45
capacity_enforcedFunction · 0.45
drain_by_peerFunction · 0.45
remove_by_idFunction · 0.45

Calls 5

nowFunction · 0.85
duration_sinceMethod · 0.80
lenMethod · 0.45
as_millisMethod · 0.45
cloneMethod · 0.45

Tested by 5

enqueue_and_dequeueFunction · 0.36
capacity_enforcedFunction · 0.36
drain_by_peerFunction · 0.36
remove_by_idFunction · 0.36