Skip unchanged live-sync streams
This commit is contained in:
parent
20fd773a42
commit
bc0ba4d169
6 changed files with 416 additions and 15 deletions
|
|
@ -571,6 +571,10 @@ pub enum PeerControlRequest {
|
|||
capability: String,
|
||||
nonce: String,
|
||||
},
|
||||
SyncStatus {
|
||||
peer_card: PeerCard,
|
||||
nonce: String,
|
||||
},
|
||||
CasFetch {
|
||||
peer_card: PeerCard,
|
||||
hash: BlobHash,
|
||||
|
|
@ -643,6 +647,15 @@ pub enum PeerControlResponse {
|
|||
nonce: String,
|
||||
note: String,
|
||||
},
|
||||
SyncStatus {
|
||||
node_id: String,
|
||||
agent_id: String,
|
||||
endpoint_id: String,
|
||||
remote_endpoint_id: String,
|
||||
watermarks: Vec<SyncWatermark>,
|
||||
nonce: String,
|
||||
note: String,
|
||||
},
|
||||
CasFetched {
|
||||
node_id: String,
|
||||
agent_id: String,
|
||||
|
|
@ -755,6 +768,12 @@ pub enum PeerControlResponse {
|
|||
},
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct SyncWatermark {
|
||||
pub stream: String,
|
||||
pub high_water: i64,
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum ControlError {
|
||||
#[error("json error: {0}")]
|
||||
|
|
@ -1118,6 +1137,24 @@ mod tests {
|
|||
response
|
||||
);
|
||||
|
||||
let response = PeerControlResponse::SyncStatus {
|
||||
node_id: "node:peer".to_owned(),
|
||||
agent_id: "agent:peer".to_owned(),
|
||||
endpoint_id: "endpoint:peer".to_owned(),
|
||||
remote_endpoint_id: "endpoint:caller".to_owned(),
|
||||
watermarks: vec![SyncWatermark {
|
||||
stream: "kv:prefs".to_owned(),
|
||||
high_water: 42,
|
||||
}],
|
||||
nonce: "nonce".to_owned(),
|
||||
note: "status".to_owned(),
|
||||
};
|
||||
assert_eq!(
|
||||
decode_peer_response(&encode_peer_response(&response).expect("encode"))
|
||||
.expect("decode"),
|
||||
response
|
||||
);
|
||||
|
||||
let response = PeerControlResponse::CasFetched {
|
||||
node_id: "node:peer".to_owned(),
|
||||
agent_id: "agent:peer".to_owned(),
|
||||
|
|
@ -1161,6 +1198,26 @@ mod tests {
|
|||
request
|
||||
);
|
||||
|
||||
let request = PeerControlRequest::SyncStatus {
|
||||
peer_card: PeerCard {
|
||||
node_id: "node:caller".into(),
|
||||
agent_id: "agent:caller".into(),
|
||||
endpoints: Vec::new(),
|
||||
issued_at: geth_types::UnixMillis(1),
|
||||
signature: geth_discovery::SignatureMetadata {
|
||||
namespace: "geth.peer-card.v1@geth.local".to_owned(),
|
||||
signer: "agent:caller".to_owned(),
|
||||
public_key: "key".to_owned(),
|
||||
signature: "sig".to_owned(),
|
||||
},
|
||||
},
|
||||
nonce: "nonce".to_owned(),
|
||||
};
|
||||
assert_eq!(
|
||||
decode_peer_request(&encode_peer_request(&request).expect("encode")).expect("decode"),
|
||||
request
|
||||
);
|
||||
|
||||
let response = PeerControlResponse::SshCertSynced {
|
||||
node_id: "node:peer".to_owned(),
|
||||
agent_id: "agent:peer".to_owned(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue