1
0
mirror of synced 2025-12-12 08:08:16 +08:00

auto commit

This commit is contained in:
yitter
2021-12-08 23:38:41 +08:00
parent 1d043bf0fe
commit ef94d9557d
5 changed files with 12 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
import time
import traceback
from IdGeneratorOptions import IdGeneratorOptions
from SnowFlake import SnowFlake
from SnowFlakeM1 import SnowFlakeM1
class DefaultIdGenerator(object):
def SetIdGernerator(self, options) :
if options.BaseTime < 100000 :
raise ValueError ("BaseTime error.")
self.SnowFlake= SnowFlakeM1(options)
def NextId(self):
return self.SnowFlake.NextId()
if __name__ == '__main__':
try:
options = IdGeneratorOptions(23)
options.BaseTime = 1231111111
idgen = DefaultIdGenerator()
idgen.SetIdGernerator(options)
print (idgen.NextId())
print (options.__dict__)
except ValueError as e:
print(e)