You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

21 lines
782 B

using Adnc.Shared.Application.IdGenerater;
using Easy.Realization;
using Easy.Snowflakes;
using Microsoft.Extensions.DependencyInjection;
using StackExchange.Redis;
namespace Easy.Extensions;
public static class ServiceCollectionServiceExtensions
{
public static IServiceCollection AddDriftingSnowflakes(this IServiceCollection services, SnowflakeOptions snowflakeOptions)
{
services.AddSingleton<ISnowflakeIdGenerator, SnowflakeIdGenerator>();
services.AddTransient(o => snowflakeOptions);
services.AddTransient(o => ConnectionMultiplexer.Connect(snowflakeOptions.RedisConnectionString).GetDatabase());
services.AddSingleton<WorkerNode>();
services.AddHostedService<WorkerNodeHostedService>();
return services;
}
}