Move push flow into SyncState methods with step callbacks
This commit is contained in:
@@ -51,16 +51,16 @@ pub struct GraspServer {
|
||||
}
|
||||
|
||||
impl GraspServer {
|
||||
fn ok(relay: RelayUrl) -> Self {
|
||||
pub(crate) fn ok(relay: RelayUrl) -> Self {
|
||||
Self {
|
||||
relay,
|
||||
reason: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn failed(relay: RelayUrl, reason: impl Into<String>) -> Self {
|
||||
pub(crate) fn failed(relay: &RelayUrl, reason: impl Into<String>) -> Self {
|
||||
Self {
|
||||
relay,
|
||||
relay: relay.to_owned(),
|
||||
reason: Some(reason.into()),
|
||||
}
|
||||
}
|
||||
@@ -150,7 +150,7 @@ where
|
||||
let Some(base) = grasp_base_url(relay) else {
|
||||
outcome
|
||||
.servers
|
||||
.push(GraspServer::failed(relay.clone(), "no domain"));
|
||||
.push(GraspServer::failed(relay, "no domain"));
|
||||
continue;
|
||||
};
|
||||
|
||||
@@ -161,9 +161,7 @@ where
|
||||
Ok(event) => event,
|
||||
Err(e) => {
|
||||
let reason = format!("could not sign the state event: {e}");
|
||||
outcome
|
||||
.servers
|
||||
.push(GraspServer::failed(relay.clone(), reason));
|
||||
outcome.servers.push(GraspServer::failed(relay, reason));
|
||||
continue;
|
||||
}
|
||||
};
|
||||
@@ -183,10 +181,7 @@ where
|
||||
};
|
||||
|
||||
if let Err(reason) = staging {
|
||||
log::warn!("grasp push failed: {relay}: {reason}");
|
||||
outcome
|
||||
.servers
|
||||
.push(GraspServer::failed(relay.clone(), reason));
|
||||
outcome.servers.push(GraspServer::failed(relay, reason));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -196,10 +191,9 @@ where
|
||||
outcome.servers.push(GraspServer::ok(relay.clone()));
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!("grasp push failed: {relay}: {e}");
|
||||
outcome
|
||||
.servers
|
||||
.push(GraspServer::failed(relay.clone(), e.to_string()));
|
||||
.push(GraspServer::failed(relay, e.to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user