Skip to main content

Crate replane

Crate replane 

Source
Expand description

Rust SDK for Replane: dynamic configuration with real-time updates.

The client keeps an SSE connection to the Replane server, holds every config of the SDK key’s project and environment in memory, and evaluates overrides locally, so reads are synchronous and the context never leaves your process.

use replane::{ConnectOptions, Context, Replane};

#[tokio::main]
async fn main() -> replane::Result<()> {
    let replane = Replane::builder()
        .default_value("rate-limit", 100)
        .connect(ConnectOptions::new("https://replane.example.com", "rp_..."))
        .await?;

    let ctx = Context::new().with("plan", "pro");
    let limit: u32 = replane.get_with("rate-limit", &ctx)?;
    println!("rate limit: {limit}");
    Ok(())
}

Structs§

Config
A config as delivered by the Replane SDK API: a base value plus overrides that are evaluated locally against the caller’s context.
ConfigChange
Notification passed to subscribers when a config changes on the server.
ConnectOptions
Options for connecting to a Replane server.
Context
Properties that overrides are evaluated against, e.g. user ID, plan or region.
Override
An override replaces the base value when all of its conditions match.
Replane
Replane client.
ReplaneBuilder
Builder for Replane.
Snapshot
A serializable copy of the client’s configs, e.g. to hydrate another client.
Subscription
Handle returned by Replane::subscribe; dropping it unsubscribes.

Enums§

Condition
An override condition with config references already resolved by the server.
ContextValue
A primitive value used for override evaluation.
EvaluationResult
ReplaneError
Errors returned by the Replane client.

Constants§

REPLANE_CLIENT_ID_KEY
Context key holding an ID generated per client, usable for segmentation. A value provided in the client context takes precedence.

Functions§

evaluate_condition
evaluate_overrides
Returns the value of the first override whose conditions all match, or base.

Type Aliases§

Result