C# implementation ADB Replication Algorithm.
- In-memory local storage.
- Configuration using
appsettings.json
. - gRPC transport.
- Async client API
- "Smart" client library encapsulating reconnection.
- Secure messaging within the cluster
- Clone repository.
- Build project in release mode.
- Generate certificate using this guide.
- Congfigure appsettings.json.
- Run run.bat.
- Open in browser
https://{node_uri}/swagger/index.html
. - Connect using default user ("admin", "12345").
- Perform put or get operations.
- Use
AddABDDB()
extension method to register dependecies.
services.AddADBDB(connectionString:"https://localhost:5001;https://localhost:5002;https://localhost:5003",
userName: "admin",
password: "12345",
options => { options.UseLoggerFactory(...); })
- Get
IDBClient
service from IoC container.
var client = provider.GetRequiredService<IDBClient>();
- Perform requests asynchronously.
var key = Random.Shared.Next(100);
var value = Random.Shared.Next(1000);
await client.PutAsync(key, value);
var result = await client.GetAsync<int, int>(key);
You can find complete example within ABDDB.ClientExample
project.
DB is configuring using appsettings.json
DB doesn't use any DNS, so you should explicitly provide all URIs and Node IDs. Node ID should be unique within the cluster.
{
"ClusterConfig": {
"Nodes": [
{
"Id": 1,
"Uri": "https://localhost:5001"
},
...
]
}
}
PFX sertificate is using for internal authentication within the cluster.
{
"SecurityConfig":
{
"Certificate": {
"Path": "certificate.pfx",
"Password": "12345"
},
"AllowedThumbprints": [
"211FCD2A8241FEFBB9C1FD1A205E14A22B6C2380"
]
}
}
This section is unnecessary. If you don't specify values, they will be set by default, as shown below (initial and max backoff are measured in seconds).
{
"TransportConfig":
{
"MaxRetryAttempts": 3,
"InitialBackoff": 2,
"MaxBackoff": 8,
"BackoffMultiplier": 2
}
}
{
"ClusterConfig": {
"Nodes": [
{
"Id": 1,
"Uri": "https://localhost:5001"
},
{
"Id": 2,
"Uri": "https://localhost:5002"
},
{
"Id": 3,
"Uri": "https://localhost:5003"
}
]
},
"SecurityConfig":
{
"Certificate": {
"Path": "certificate.pfx",
"Password": "12345"
},
"AllowedThumbprints": [
"211FCD2A8241FEFBB9C1FD1A205E14A22B6C2380"
]
},
"TransportConfig":
{
"MaxRetryAttempts": 3,
"InitialBackoff": 2,
"MaxBackoff": 8,
"BackoffMultiplier": 2
}
}