Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hueifeng/snowflake-csharp
Twitter's SnowFlake algorithm is implemented using C# language. Support on redis to determine the machine serial number, Full support of cloud native K8S.
https://github.com/hueifeng/snowflake-csharp
csharp distributed kubernetes redis snowflake snowflake-algorithm twitter unique-id
Last synced: 10 days ago
JSON representation
Twitter's SnowFlake algorithm is implemented using C# language. Support on redis to determine the machine serial number, Full support of cloud native K8S.
- Host: GitHub
- URL: https://github.com/hueifeng/snowflake-csharp
- Owner: hueifeng
- License: apache-2.0
- Created: 2020-06-19T12:08:05.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-08-30T06:38:24.000Z (2 months ago)
- Last Synced: 2024-10-13T07:07:52.546Z (24 days ago)
- Topics: csharp, distributed, kubernetes, redis, snowflake, snowflake-algorithm, twitter, unique-id
- Language: C#
- Homepage:
- Size: 209 KB
- Stars: 24
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Description
Language: English | [中文](README.zh-cn.md)
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.
```csharp
SnowFlake snowFlake = new SnowFlake(datacenterId:1,machineId:1);
```2. Generate Id.
```csharp
var id = snowFlake.NextId();
```## Advanced
Support Kubernetes HorizontalPodAutoscaler.1. Used in distributed.
```
PM> Install-Package Snowflake.Redis.CSharp
```2. Add the following code at ConfigureServices() method.
```csharp
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](LICENSE)