Function create_region

Source
pub async fn create_region(
    pool: &Pool<MySql>,
    name: &str,
    provider: &str,
    status: &str,
) -> Result<Region>
Expand description

Creates a new deployment region in the system.

This function registers a new region for application deployments. Regions typically represent geographical deployment locations or distinct cloud provider environments.

§Arguments

  • pool - Database connection pool for executing the query
  • name - Name of the region (typically a geographical identifier like “us-east”, “eu-west”)
  • provider - Cloud or infrastructure provider (e.g., “aws”, “gcp”, “azure”, “on-prem”)
  • status - Initial status of the region (e.g., “provisioning”, “active”, “maintenance”)

§Returns

  • Ok(Region) - Successfully created region record
  • Err(anyhow::Error) - Failed to create region record

§Transaction Handling

This function uses a database transaction to ensure atomicity of the operation. If any part of the operation fails, the entire operation is rolled back.

§Common Region States

Typical region status values include:

  • “provisioning” - Region is being set up and not yet ready for deployments
  • “active” - Region is fully operational and can accept deployments
  • “maintenance” - Region is temporarily unavailable for new deployments
  • “deprecated” - Region is being phased out, no new deployments accepted
  • “unavailable” - Region is not currently operational