Skip to content

Commit 3afeb71

Browse files
authored
Merge pull request #3786 from itowlson/redis-outbound-connection-timeout
Set a timeout on Redis outbound connections
2 parents 1399776 + 4d0accc commit 3afeb71

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

  • crates/factor-outbound-redis/src

‎crates/factor-outbound-redis/src/host.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ use tracing::{Level, instrument};
1818

1919
use crate::allowed_hosts::AllowedHostChecker;
2020

21+
const REDIS_CONNECTION_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(30);
22+
2123
pub struct InstanceState {
2224
pub(crate) allowed_host_checker: AllowedHostChecker,
2325
pub blocked_networks: BlockedNetworks,
@@ -44,7 +46,8 @@ impl InstanceState {
4446
.await
4547
.map_err(|_| v2::Error::TooManyConnections)?;
4648
let config = AsyncConnectionConfig::new()
47-
.set_dns_resolver(SpinDnsResolver(self.blocked_networks.clone()));
49+
.set_dns_resolver(SpinDnsResolver(self.blocked_networks.clone()))
50+
.set_connection_timeout(REDIS_CONNECTION_TIMEOUT);
4851
let conn = redis::Client::open(address.as_str())
4952
.map_err(|_| v2::Error::InvalidAddress)?
5053
.get_multiplexed_async_connection_with_config(&config)

0 commit comments

Comments
 (0)