You can not select more than 25 topics
Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- 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)
-
|