Code Monkey home page Code Monkey logo

slik's Introduction

Build Integration tests Nuget The current version of Slik.Cache Slik.Cache uses MIT License

Slik.Cache

Distributed In-process Cache in C# and Net 5.0/6.0 with external gRPC API (HTTP/2, client/server certificates)

Based on a magnificent dotNext library and its Raft cluster implementation.

Implements IDistributedCache, a standard interface for .Net Core cache.

Simple initialization:

await Host
    .CreateDefaultBuilder()
    .UseSlik(new SlikOptions 
    { 
        Host = new IPEndPoint(IPAddress.Loopback, 3092),
        Members = new[] { "localhost:3092", "localhost:3093", "localhost:3094" }
    })
    .Build()
    .RunAsync();

Usage:

public class CacheConsumer
{
  private readonly IDistributedCache _cache;

  public CacheConsumer(IDistributedCache cache)
  {
      _cache = cache;
      _cache.SetString("Greeting", "Hello, world");
  }
  
  //...  
}

Update any node, updates are redirected to a cluster leader, and are replicated automatically to each node.

Sample project: examples/SlikNode

How to run a minimal cluster:

SlikNode --port=3092 --folder="node 1" --members=localhost:3092,localhost:3093,localhost:3094
SlikNode --port=3093 --folder="node 2" --members=localhost:3092,localhost:3093,localhost:3094
SlikNode --port=3094 --folder="node 3" --members=localhost:3092,localhost:3093,localhost:3094

Roadmap

  • Self-signed certificates generation
  • Support adding/removal of cluster members in runtime
  • More unit and integration tests to cover adding/removing cluster members
  • Docker compose for starting cluster in containers
  • Use IMemberDiscoveryService instead of config changes for cluster membership
  • Decouple command handling with Interpreter Framework
  • Optimize log entries, binary format instead of JSON
  • Backgound log compaction
  • Distributed locks

Slik.Cord tests

Slik.Cord

A gRPC HTTP proxy for containerd in C# and Net 5.0/6.0. Containerd API works locally via Unix domain socket (in Linux) or named pipe (in Windows), not allowing to connect to it from another computer/container. This proxy can solve the problem. Current implementation doesn't work on Windows.

Usage

Run SlikCord (preferably in a container). Connect to port 80 from any client with gRPC support using the regular containerd API.

Roadmap

  • Support for all containerd APIs
  • Integration tests for containers, images, version, content, events, introspection, namespaces
  • Integration tests for diff, leases, snapshots, tasks, ttrpc-events
  • Switch to HTTPS
  • Support self-signed certificates
  • Named pipes support
  • Unix domain socket on Linux support
  • Unix domain socket on Windows support

slik's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

slik's Issues

[Discussion] Extending functionality of Silk and refactorings

Hi @Insvald , I would like to join in your project. I see that some refactoring can be applied:

  • Membership changes. My library offers IMemberServiceDiscovery that allows to replace member discovery based on configuration. It was especially designed to be compatible with third-party discovery mechanisms such as Kubernetes or Consul. I think it's better to provide extensibility here in Slik
  • JSON format of log entries may be not the best choice for performance reasons
  • Moving to Interpreter Framework to decouple command handling
  • Various optimization for log entry serialization/deserialization to increase throughput
  • Moving to background log compaction instead of sequential log compaction
  • Introduce distributed locks. The locks were previously added to .NEXT library but then I decided to drop them so it was never released. Now your project is appropriate place for them IMO.

How to use Slik in a .NET 6 Web Api project?

I'm trying to create a REST API project using Slik.Cache, code example:

            WebApplicationBuilder builder = WebApplication.CreateBuilder();
            builder.Host.UseSlik(new SlikOptions
            {
                Host = new IPEndPoint(IPAddress.Loopback, 3092),
                Members = new[] { "localhost:3092", "localhost:3093", "localhost:3094" }
            });

            builder.Services.AddControllers();
            // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
            builder.Services.AddEndpointsApiExplorer();
            builder.Services.AddSwaggerGen();

            var app = builder.Build();

            // Configure the HTTP request pipeline.
            if (app.Environment.IsDevelopment())
            {
                app.UseSwagger();
                app.UseSwaggerUI();
            }

            app.UseAuthorization();
            app.MapControllers();

            app.Run();

But I get exception `System.NotSupportedException: 'ConfigureWebHost() is not supported by WebApplicationBuilder.Host. Use the WebApplication returned by WebApplicationBuilder.Build() instead.'.

Do I need to modify something to make it work?

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.