SnowflakeId.AutoRegister.SqlServer 1.0.1

dotnet add package SnowflakeId.AutoRegister.SqlServer --version 1.0.1                
NuGet\Install-Package SnowflakeId.AutoRegister.SqlServer -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SnowflakeId.AutoRegister.SqlServer" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SnowflakeId.AutoRegister.SqlServer --version 1.0.1                
#r "nuget: SnowflakeId.AutoRegister.SqlServer, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SnowflakeId.AutoRegister.SqlServer as a Cake Addin
#addin nuget:?package=SnowflakeId.AutoRegister.SqlServer&version=1.0.1

// Install SnowflakeId.AutoRegister.SqlServer as a Cake Tool
#tool nuget:?package=SnowflakeId.AutoRegister.SqlServer&version=1.0.1                

SnowflakeId AutoRegister

Latest version License LGPLv3 Coverity Scan

Is a C# library for automatic registration of WorkerId in SnowflakeId systems, supporting SQL Server, Redis , and other.
Itself does not provide the generation of Snowflake Id, it only helps you to automatically register WorkerId.
In theory, SnowflakeId AutoRegister can be integrated with any framework that utilizes SnowflakeId

Getting Started

SnowflakeId AutoRegister is a library that provides a simple way to automatically register WorkerId in SnowflakeId systems.
Itself does not provide the generation of Snowflake Id, it only helps you to automatically register WorkerId.

Prerequisites

  • .NETStandard 2.0
  • Support Redis
  • Support SQL Server
  • More storage mechanisms will be supported in future updates

Installation

SnowflakeId.AutoRegister is available as a NuGet package. You can install it using the NuGet Package Console window:

Install the core package

Install-Package SnowflakeId.AutoRegister

Use Redis

Install-Package SnowflakeId.AutoRegister.Redis

Use SqlServer

Install-Package SnowflakeId.AutoRegister.SqlServer

Usage

Use the AutoRegisterBuilder to create a singleton instance of IAutoRegister.

static readonly IAutoRegister AutoRegister = new AutoRegisterBuilder()
    // Register Option
    // Use the following line to set the identifier.
    // Recommended setting to distinguish multiple applications on a single machine
   .SetExtraIdentifier(Environment.CurrentDirectory)
    // Use the following line to set the WorkerId scope.
   .SetWorkerIdScope(1, 31)
    // Use the following line to set the register option.
    // .SetRegisterOption(option => {})

    // Use the following line to use the default store.
    // Only suitable for standalone use, local testing, etc.
    //.UseDefaultStore()
        
    // Use the following line to use the Redis store.
    .UseRedisStore("localhost:6379,allowAdmin=true")
       
    // Use the following line to use the SQL Server store.
    //.UseSqlServerStore("Server=localhost;Database=IdGenerator;User Id=sa;Password=123456;")
    Build();

Use the AutoRegister instance to get the SnowflakeIdConfig.

// Use Register WorkerId.
SnowflakeIdConfig config = AutoRegister.Register();
Console.WriteLine($"WorkerId: {config.WorkerId}");
Yitter.IdGenerator AutoRegister
var config = AutoRegister.Register();
var options = new IdGeneratorOptions
{
    WorkerId = (ushort)config.WorkerId,
};
IIdGenerator idGenInstance = new DefaultIdGenerator(options);
long id = idGenInstance.NewLong();
Console.WriteLine($"Id: {id}");

Other AutoRegister

For other Snowflake ID generation libraries, please refer to the Yitter.IdGenerator Demo.

Building the sources

Clone the repository:

git clone https://github.com/LemonNoCry/SnowflakeId.AutoRegister.git

Navigate to the project directory:

cd SnowflakeId.AutoRegister 

Restore the packages:

dotnet restore 

Build the project:

dotnet build

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on SnowflakeId.AutoRegister.SqlServer:

Repository Stars
anjoy8/Blog.Core
💖 ASP.NET Core 8.0 全家桶教程,前后端分离后端接口,vue教程姊妹篇,官方文档:
Version Downloads Last updated
1.0.1 212 7/6/2024
1.0.0 2,237 7/2/2024