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