Skip to content

Twitter's SnowFlake algorithm is implemented using C# language. Support on redis to determine the machine serial number, Full support of cloud native K8S.

License

Notifications You must be signed in to change notification settings

hueifeng/snowflake-csharp

Repository files navigation

An ID Generator for C# based on Snowflake Algorithm (Twitter announced).

nuget NETCore stats LICENSE FOSSA

Description

Language: English | 中文

Twitter's SnowFlake algorithm is implemented using C# language.

Installation

PM> Install-Package Snowflake.CSharp

Useage

  1. Specify the data center ID and machine ID.
SnowFlake snowFlake = new SnowFlake(datacenterId:1,machineId:1);
  1. Generate Id.
var id = snowFlake.NextId();

Advanced

Support Kubernetes HorizontalPodAutoscaler.

  1. Used in distributed.
PM> Install-Package Snowflake.Redis.CSharp
  1. Add the following code at ConfigureServices() method.
public void ConfigureServices(IServiceCollection services)
{
  services.AddSnowflakeRedisService(connectionString:"127.0.0.1:6379,allowAdmin=true", 
      option 
            =>Configuration.GetSection("snowFlake").Bind(option)
     );
}

Distributed snowflake ID automated configuration of different machine ids.

"snowFlake": {
  "dataCenterId": 1,
  "Name": "test"
} 

License

Apache

About

Twitter's SnowFlake algorithm is implemented using C# language. Support on redis to determine the machine serial number, Full support of cloud native K8S.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages