plans/2025-04-06-retry-config-migration.md
The objective is to move the retry configuration from the Workflow struct to the Environment struct and enable configuration via environment variables. This will provide flexibility and a centralized location for retry configuration that can be accessed by various components without relying on the workflow repository.
Modify the Environment struct in crates/forge_domain/src/env.rs to include a RetryConfig field.
#[derive(Debug, Setters, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[setters(strip_option)]
pub struct Environment {
// Existing fields...
/// Configuration for the retry mechanism
pub retry_config: RetryConfig,
}
Enhance ForgeEnvironmentService in crates/forge_infra/src/env.rs to read retry configuration from environment variables:
FORGE_RETRY_INITIAL_BACKOFF_MS - Initial backoff delay in millisecondsFORGE_RETRY_BACKOFF_FACTOR - Multiplication factor for each retry attemptFORGE_RETRY_MAX_ATTEMPTS - Maximum number of retry attemptsFORGE_RETRY_STATUS_CODES - Comma-separated list of HTTP status codes that should trigger retriesThe service should read these variables and use them to configure the RetryConfig instance, falling back to default values if the environment variables are not set.
Remove the retry field from the Workflow struct in crates/forge_domain/src/workflow.rs.
Modify the ForgeProviderService::new method in crates/forge_services/src/provider.rs to obtain the retry configuration from the environment rather than from the workflow:
pub fn new<F: Infrastructure>(infra: Arc<F>) -> Self {
let infra = infra.clone();
let env = infra.environment_service().get_environment();
let provider = env.provider.clone();
let retry_config = env.retry_config;
Self {
client: Arc::new(Client::new(provider, retry_config).unwrap()),
}
}
Update the WorkflowRepository trait in crates/forge_services/src/infra.rs to remove any references to retry configuration.
Modify the ForgeWorkflowRepository implementation in crates/forge_infra/src/workflow.rs to reflect the changes in the Workflow struct.
Update any tests that rely on the retry field in the Workflow struct to use the new field in Environment instead.
Update the documentation to explain how to configure retry settings using environment variables.
Environment.