collect request_metadata.response_from_backup_rpc
This commit is contained in:
parent
a820b55987
commit
b9a12756b9
@ -85,6 +85,7 @@ pub struct RequestMetadata {
|
||||
pub error_response: AtomicBool,
|
||||
pub response_bytes: AtomicU64,
|
||||
pub response_millis: AtomicU64,
|
||||
pub response_from_backup_rpc: AtomicBool,
|
||||
}
|
||||
|
||||
impl RequestMetadata {
|
||||
@ -103,6 +104,7 @@ impl RequestMetadata {
|
||||
error_response: false.into(),
|
||||
response_bytes: 0.into(),
|
||||
response_millis: 0.into(),
|
||||
response_from_backup_rpc: false.into(),
|
||||
};
|
||||
|
||||
Ok(new)
|
||||
|
@ -723,6 +723,7 @@ impl Web3Connections {
|
||||
|
||||
// TODO: maximum retries? right now its the total number of servers
|
||||
loop {
|
||||
// TODO: is self.conns still right now that we split main and backup servers?
|
||||
if skip_rpcs.len() == self.conns.len() {
|
||||
// no servers to try
|
||||
break;
|
||||
@ -738,14 +739,17 @@ impl Web3Connections {
|
||||
{
|
||||
OpenRequestResult::Handle(active_request_handle) => {
|
||||
// save the rpc in case we get an error and want to retry on another server
|
||||
// TODO: look at backend_requests instead
|
||||
skip_rpcs.push(active_request_handle.clone_connection());
|
||||
|
||||
if let Some(request_metadata) = request_metadata {
|
||||
// TODO: request_metadata.backend_requests instead of skip_rpcs
|
||||
let rpc = active_request_handle.clone_connection();
|
||||
|
||||
request_metadata
|
||||
.backend_requests
|
||||
.lock()
|
||||
.push(active_request_handle.clone_connection());
|
||||
.response_from_backup_rpc
|
||||
.store(rpc.backup, Ordering::Release);
|
||||
|
||||
request_metadata.backend_requests.lock().push(rpc);
|
||||
}
|
||||
|
||||
// TODO: get the log percent from the user data
|
||||
@ -896,10 +900,24 @@ impl Web3Connections {
|
||||
// TODO: this is not working right. simplify
|
||||
|
||||
if let Some(request_metadata) = request_metadata {
|
||||
let mut backup_used = false;
|
||||
|
||||
request_metadata.backend_requests.lock().extend(
|
||||
active_request_handles.iter().map(|x| {
|
||||
let rpc = x.clone_connection();
|
||||
|
||||
if rpc.backup {
|
||||
// TODO: its possible we serve from a synced connection though. think about this more
|
||||
backup_used = true;
|
||||
}
|
||||
|
||||
x.clone_connection()
|
||||
}),
|
||||
);
|
||||
|
||||
request_metadata
|
||||
.backend_requests
|
||||
.lock()
|
||||
.extend(active_request_handles.iter().map(|x| x.clone_connection()));
|
||||
.response_from_backup_rpc
|
||||
.store(true, Ordering::Release);
|
||||
}
|
||||
|
||||
return self
|
||||
|
Loading…
Reference in New Issue
Block a user