fix allow_not_ready

This commit is contained in:
Bryan Stitt 2022-12-20 21:47:41 -08:00
parent fc48f2469c
commit c0b457cec8
2 changed files with 9 additions and 3 deletions

@ -14,7 +14,7 @@ use std::sync::Arc;
/// Health check page for load balancers to use.
#[debug_handler]
pub async fn health(Extension(app): Extension<Arc<Web3ProxyApp>>) -> impl IntoResponse {
// TODO: also check that the head block is not too old
// TODO: add a check that we aren't shutting down
if app.balanced_rpcs.synced() {
(StatusCode::OK, "OK")
} else {

@ -483,7 +483,10 @@ impl Web3Connections {
// now that the rpcs are sorted, try to get an active request handle for one of them
for best_rpc in sorted_rpcs.into_iter() {
// increment our connection counter
match best_rpc.try_request_handle(authorization, false).await {
match best_rpc
.try_request_handle(authorization, min_block_needed.is_none())
.await
{
Ok(OpenRequestResult::Handle(handle)) => {
trace!("opened handle: {}", best_rpc);
return Ok(OpenRequestResult::Handle(handle));
@ -551,7 +554,10 @@ impl Web3Connections {
}
// check rate limits and increment our connection counter
match connection.try_request_handle(authorization, false).await {
match connection
.try_request_handle(authorization, block_needed.is_none())
.await
{
Ok(OpenRequestResult::RetryAt(retry_at)) => {
// this rpc is not available. skip it
earliest_retry_at = earliest_retry_at.min(Some(retry_at));