/// <summary> /// 构造一个 <see cref="AbstractAccessorSeeder"/>。 /// </summary> /// <param name="clock">给定的 <see cref="IClockBootstrap"/>。</param> /// <param name="idGeneratorFactory">给定的 <see cref="IIdGeneratorFactory"/>。</param> protected AbstractAccessorSeeder(IClockBootstrap clock, IIdGeneratorFactory idGeneratorFactory) { SeedBank = new ConcurrentDictionary <string, object>(); Clock = clock; IdGeneratorFactory = idGeneratorFactory; }
/// <summary> /// 构造一个 <see cref="SnowflakeIdGenerator"/>。 /// </summary> /// <param name="snowflakes">给定的 <see cref="SnowflakeIdOptions"/>。</param> /// <param name="options">给定的 <see cref="IdGenerationOptions"/>。</param> /// <param name="clock">给定的 <see cref="IClockBootstrap"/>。</param> public SnowflakeIdGenerator(SnowflakeIdOptions snowflakes, IdGenerationOptions options, IClockBootstrap clock) : base(options, clock) { Snowflakes = snowflakes; if (options.MachineId >= 0) { _machineId = options.MachineId.NotGreater(Snowflakes.GetMaxMachineId()); } else { _machineId = Snowflakes.MachineBits; } if (options.DataCenterId >= 0) { _dataCenterId = options.DataCenterId.NotGreater(Snowflakes.GetMaxDataCenterId()); } else { _dataCenterId = Snowflakes.DataCenterBits; } }
/// <summary> /// 构造一个 <see cref="CombSnowflakeIdGenerator"/>。 /// </summary> /// <param name="options">给定的 <see cref="IdGenerationOptions"/>。</param> /// <param name="clock">给定的 <see cref="IClockBootstrap"/>。</param> public CombSnowflakeIdGenerator(IdGenerationOptions options, IClockBootstrap clock) : base(options, clock) { _workId = options.WorkId; }
/// <summary> /// 构造一个 <see cref="AbstractClockIdGenerator{TId}"/>。 /// </summary> /// <param name="options">给定的 <see cref="IdGenerationOptions"/>。</param> /// <param name="clock">给定的 <see cref="IClockBootstrap"/>。如使用本地时钟可参考 <see cref="Bootstrapper.GetClock()"/>。</param> protected AbstractClockIdGenerator(IdGenerationOptions options, IClockBootstrap clock) { Options = options; Clock = clock; }
/// <summary> /// 构造一个 <see cref="CombIdGenerator"/>。 /// </summary> /// <param name="generation">给定的 <see cref="CombIdGeneration"/>。</param> /// <param name="options">给定的 <see cref="IdGenerationOptions"/>。</param> /// <param name="clock">给定的 <see cref="IClockBootstrap"/>。</param> public CombIdGenerator(CombIdGeneration generation, IdGenerationOptions options, IClockBootstrap clock) : base(options, clock) { Generation = generation; }
/// <summary> /// 构造一个 <see cref="MongoIdGenerator"/>。 /// </summary> /// <param name="mongos">给定的 <see cref="MongoIdOptions"/>。</param> /// <param name="options">给定的 <see cref="IdGenerationOptions"/>。</param> /// <param name="clock">给定的 <see cref="IClockBootstrap"/>。</param> public MongoIdGenerator(MongoIdOptions mongos, IdGenerationOptions options, IClockBootstrap clock) : base(options, clock) { Mongos = mongos; }