A simple console application demonstrating basic Replane SDK usage.
- .NET 8.0 SDK or later
- A running Replane server
- An SDK key from your Replane project
-
Copy this directory to your local machine:
cp -r BasicUsage ~/my-replane-example cd ~/my-replane-example
-
Set your environment variables:
export REPLANE_BASE_URL="https://your-replane-server.com" export REPLANE_SDK_KEY="your-sdk-key"
Or edit
Program.csdirectly to set the values. -
Restore packages:
dotnet restore
dotnet runConnecting to Replane server...
Connected successfully!
feature-enabled: false
max-items: 10
timeout-ms: 5000
Expected error: Config 'non-existent-config' not found
- Creating and configuring a
ReplaneClient - Connecting to the Replane server
- Reading typed config values with
Get<T>() - Using default values
- Proper error handling
- Resource cleanup with
DisposeAsync()
Default values are used when:
- The server hasn't sent a config yet
- The config doesn't exist on the server
Defaults = new Dictionary<string, object?>
{
["feature-enabled"] = false,
["max-items"] = 10
}You can also provide a default at read time:
// Returns 5000 if "timeout-ms" doesn't exist
var timeout = client.Get<int>("timeout-ms", defaultValue: 5000);The SDK throws specific exceptions:
AuthenticationException- Invalid SDK keyConfigNotFoundException- Config not found (and no default provided)ReplaneTimeoutException- Connection or request timeoutReplaneException- Base class for all Replane errors