better error if no redis client pool

This commit is contained in:
Bryan Stitt 2022-07-25 19:03:19 +00:00
parent b59a3c8d91
commit 8ff394137c
3 changed files with 14 additions and 5 deletions

@ -1,7 +1,7 @@
[shared]
chain_id = 1
# in prod, do `rate_limit_redis = "redis://redis:6379/"`
#rate_limit_redis = "redis://dev-redis:6379/"
# in prod, do `redis_url = "redis://redis:6379/"`
#redis_url = "redis://dev-redis:6379/"
public_rate_limit_per_minute = 60_000
# 1GB of cache
response_cache_max_bytes = 10 ^ 9

@ -330,7 +330,7 @@ impl Web3ProxyApp {
Some(pool)
}
None => {
info!("No redis address");
warn!("No redis address");
None
}
};

@ -75,14 +75,23 @@ impl Web3ConnectionConfig {
block_sender: Option<flume::Sender<BlockAndRpc>>,
tx_id_sender: Option<flume::Sender<(TxHash, Arc<Web3Connection>)>>,
) -> anyhow::Result<(Arc<Web3Connection>, AnyhowJoinHandle<()>)> {
let hard_rate_limit = self.hard_limit.map(|x| (x, redis_client_pool.unwrap()));
let hard_limit = match (self.hard_limit, redis_client_pool) {
(None, None) => None,
(Some(hard_limit), Some(redis_client_pool)) => Some((hard_limit, redis_client_pool)),
(None, Some(_)) => None,
(Some(hard_limit), None) => {
return Err(anyhow::anyhow!(
"no redis client pool! needed for hard limit"
))
}
};
Web3Connection::spawn(
chain_id,
self.url,
http_client,
http_interval_sender,
hard_rate_limit,
hard_limit,
self.soft_limit,
block_sender,
tx_id_sender,