fix: repair proven unsent sync chain with signed archived receipt
Rust development slice / linux (push) Failing after 7s
Rust development slice / linux (push) Failing after 7s
This commit is contained in:
@@ -116,7 +116,10 @@ async fn receive(socket: &mut WebSocket) -> Result<Envelope> {
|
||||
Ok(Envelope::decode(bytes)?)
|
||||
}
|
||||
async fn send(
|
||||
state: &crate::State,
|
||||
socket: &mut WebSocket,
|
||||
tenant: Uuid,
|
||||
agent: Uuid,
|
||||
e: &Envelope,
|
||||
payload: Payload,
|
||||
generation: u64,
|
||||
@@ -133,11 +136,22 @@ async fn send(
|
||||
sequence: e.sequence,
|
||||
payload: Some(payload),
|
||||
};
|
||||
let claim =
|
||||
dev_delivery_faults::duplicate_offer(&state.pool, tenant, agent, &reply, "wss").await?;
|
||||
let bytes = reply.encode_to_vec();
|
||||
tokio::time::timeout(
|
||||
Duration::from_secs(10),
|
||||
socket.send(Message::Binary(reply.encode_to_vec().into())),
|
||||
socket.send(Message::Binary(bytes.clone().into())),
|
||||
)
|
||||
.await??;
|
||||
if let Some(claim) = claim {
|
||||
tokio::time::timeout(
|
||||
Duration::from_secs(10),
|
||||
socket.send(Message::Binary(bytes.into())),
|
||||
)
|
||||
.await??;
|
||||
dev_delivery_faults::duplicate_emitted(&state.pool, claim).await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
async fn channel(
|
||||
@@ -162,7 +176,7 @@ async fn channel(
|
||||
.send(Message::Binary(response.encode_to_vec().into()))
|
||||
.await?;
|
||||
if let Some(payload) = crate::job_gateway::next(state, tenant, agent, generation).await? {
|
||||
send(socket, &hello, payload, generation).await?;
|
||||
send(state, socket, tenant, agent, &hello, payload, generation).await?;
|
||||
}
|
||||
let mut recent_messages = VecDeque::new();
|
||||
let mut timer = tokio::time::interval(Duration::from_secs(1));
|
||||
@@ -177,7 +191,7 @@ async fn channel(
|
||||
let mut tx=rmm_persistence::tenant_tx(&state.pool,tenant).await?;
|
||||
let revoked:bool=sqlx::query_scalar("SELECT revoked_at IS NOT NULL FROM agent_installations WHERE agent_id=$1").bind(agent).fetch_one(&mut *tx).await?;
|
||||
tx.commit().await?;ensure!(!revoked,"device revoked");
|
||||
if let Some(payload)=crate::job_gateway::next(state,tenant,agent,generation).await?{send(socket,&hello,payload,generation).await?;}
|
||||
if let Some(payload)=crate::job_gateway::next(state,tenant,agent,generation).await?{send(state,socket,tenant,agent,&hello,payload,generation).await?;}
|
||||
continue;
|
||||
}
|
||||
};
|
||||
@@ -198,11 +212,17 @@ async fn channel(
|
||||
"channel generation mismatch"
|
||||
);
|
||||
let response = crate::agent_service::ingest(state, tenant, agent, &e, "wss").await?;
|
||||
socket
|
||||
.send(Message::Binary(response.encode_to_vec().into()))
|
||||
.await?;
|
||||
if !dev_delivery_faults::after_ingest(&state.pool, tenant, agent, &e, &response, "wss")
|
||||
.await?
|
||||
{
|
||||
socket
|
||||
.send(Message::Binary(response.encode_to_vec().into()))
|
||||
.await?;
|
||||
}
|
||||
if let Some(payload) = crate::job_gateway::next(state, tenant, agent, generation).await? {
|
||||
send(socket, &e, payload, generation).await?;
|
||||
send(state, socket, tenant, agent, &e, payload, generation).await?;
|
||||
}
|
||||
}
|
||||
}
|
||||
#[path = "dev_delivery_faults.rs"]
|
||||
pub(crate) mod dev_delivery_faults;
|
||||
|
||||
Reference in New Issue
Block a user