Skip to content

Quick Start

This guide will walk you through deploying your first Redis database with Senren.

Deploy Redis

Create a Redis database in your production namespace:

use senren::*;

#[tokio::main]
async fn main() -> Result<()> {
    // Connect to control plane
    let client = SenrenClient::connect("http://senren-api:50051").await?;

    // Define Redis database
    let redis = RedisDatabase {
        name: "user-cache",
        namespace: "production",
        region: "us-central",
        memory_mb: 512,
    };

    // Apply state
    let response = client.apply_state(State {
        databases: vec![redis],
    }).await?;

    println!("Applied version: {}", response.applied_version);
    Ok(())
}

What Happens Next?

  1. Control Plane stores the desired state in PostgreSQL
  2. Kafka receives the state change message
  3. Regional Plane (in us-central) sees the message and creates a Redis CRD
  4. Controller watches the CRD and provisions: - StatefulSet with Redis pod - Service for network access - Updates CRD status
  5. Status flows back: Controller → CRD → Regional Plane → Kafka → Control Plane

Check Status

// Query resource status
let status = client.get_redis_status("production", "user-cache").await?;

println!("Ready: {}", status.ready);
println!("Host: {}", status.host);
println!("Port: {}", status.port);

Connect to Redis

Once ready, connect using the status information:

let redis_client = redis::Client::open(format!(
    "redis://{}:{}",
    status.host,
    status.port
))?;

let mut conn = redis_client.get_connection()?;
redis::cmd("SET").arg("hello").arg("world").execute(&mut conn);

Multi-Region Deployment

Deploy the same database to multiple regions:

let databases = vec![
    RedisDatabase {
        name: "user-cache",
        namespace: "production",
        region: "us-central",
        memory_mb: 512,
    },
    RedisDatabase {
        name: "user-cache",
        namespace: "production",
        region: "eu-west",
        memory_mb: 512,
    },
];

client.apply_state(State { databases }).await?;

Senren will provision the database in both regions automatically.

Update Configuration

Change the memory allocation:

let redis = RedisDatabase {
    name: "user-cache",
    namespace: "production",
    region: "us-central",
    memory_mb: 1024,  // Changed from 512
};

client.apply_state(State {
    databases: vec![redis],
}).await?;

The controller will update the StatefulSet with the new memory limit.

Delete Resources

Remove the database by sending empty state:

client.apply_state(State {
    databases: vec![],
}).await?;

Next Steps