Giter VIP home page Giter VIP logo

abd-database's Introduction

ADB Database


It's not production-ready solution!

C# implementation ADB Replication Algorithm.

Features


  1. In-memory local storage.
  2. Configuration using appsettings.json.
  3. gRPC transport.
  4. Async client API
  5. "Smart" client library encapsulating reconnection.
  6. Secure messaging within the cluster

Getting started


  1. Clone repository.
  2. Build project in release mode.
  3. Generate certificate using this guide.
  4. Congfigure appsettings.json.
  5. Run run.bat.

Connecting to the cluster


Connecting using Swagger

  1. Open in browser https://{node_uri}/swagger/index.html.
  2. Connect using default user ("admin", "12345").
  3. Perform put or get operations.

Connecting using client library

  1. 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(...); })
  1. Get IDBClient service from IoC container.
    var client = provider.GetRequiredService<IDBClient>();
  1. 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.

Configuration


DB is configuring using appsettings.json

Cluster configuration

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"
          },
          ...
        ]
    }
}

Security Configuration

PFX sertificate is using for internal authentication within the cluster.

{
    "SecurityConfig": 
      {
        "Certificate": {
          "Path": "certificate.pfx",
          "Password": "12345"
        },
        "AllowedThumbprints": [
          "211FCD2A8241FEFBB9C1FD1A205E14A22B6C2380"
        ]
      }
}

Transport configuration

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
      }
}

Full config example:

   {
      "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
      }
    }

abd-database's People

Stargazers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.