148 148 | }
|
149 149 |
|
150 150 | fn validate_retry_config(
|
151 151 | components: &RuntimeComponentsBuilder,
|
152 152 | cfg: &ConfigBag,
|
153 153 | ) -> Result<(), BoxError> {
|
154 154 | if let Some(retry_config) = cfg.load::<RetryConfig>() {
|
155 155 | if retry_config.has_retry() && components.sleep_impl().is_none() {
|
156 156 | Err("An async sleep implementation is required for retry to work. Please provide a `sleep_impl` on \
|
157 157 | the config, or disable timeouts.".into())
|
158 158 | } else {
|
159 159 | Ok(())
|
160 160 | }
|
161 161 | } else {
|
162 162 | Err(
|
163 163 | "The default retry config was removed, and no other config was put in its place."
|
164 164 | .into(),
|
165 165 | )
|
166 166 | }
|
167 167 | }
|
168 168 |
|
169 169 | /// Runtime plugin that sets the default timeout config (no timeouts).
|
170 170 | pub fn default_timeout_config_plugin() -> Option<SharedRuntimePlugin> {
|
171 171 | Some(
|
172 172 | default_plugin("default_timeout_config_plugin", |components| {
|
173 173 | components.with_config_validator(SharedConfigValidator::base_client_config_fn(
|
174 174 | validate_timeout_config,
|
175 175 | ))
|
176 176 | })
|
177 177 | .with_config(layer("default_timeout_config", |layer| {
|
178 - | layer.store_put(TimeoutConfig::disabled());
|
178 + | layer.store_put(
|
179 + | TimeoutConfig::builder()
|
180 + | .connect_timeout(Duration::from_millis(3100))
|
181 + | .build(),
|
182 + | );
|
179 183 | }))
|
180 184 | .into_shared(),
|
181 185 | )
|
182 186 | }
|
183 187 |
|
184 188 | fn validate_timeout_config(
|
185 189 | components: &RuntimeComponentsBuilder,
|
186 190 | cfg: &ConfigBag,
|
187 191 | ) -> Result<(), BoxError> {
|
188 192 | if let Some(timeout_config) = cfg.load::<TimeoutConfig>() {
|
189 193 | if timeout_config.has_timeouts() && components.sleep_impl().is_none() {
|
190 194 | Err("An async sleep implementation is required for timeouts to work. Please provide a `sleep_impl` on \
|
191 195 | the config, or disable timeouts.".into())
|
192 196 | } else {
|
193 197 | Ok(())
|
194 198 | }
|
195 199 | } else {
|
196 200 | Err(
|
197 201 | "The default timeout config was removed, and no other config was put in its place."
|
198 202 | .into(),
|
199 203 | )
|
200 204 | }
|
201 205 | }
|
202 206 |
|
203 207 | /// Runtime plugin that registers the default identity cache implementation.
|
204 208 | pub fn default_identity_cache_plugin() -> Option<SharedRuntimePlugin> {
|
205 209 | Some(
|
206 210 | default_plugin("default_identity_cache_plugin", |components| {
|
207 211 | components.with_identity_cache(Some(IdentityCache::lazy().build()))
|
208 212 | })
|