def configure_client(cls, config): flake_id_config = FlakeIdGeneratorConfig("short-term") flake_id_config.prefetch_count = SHORT_TERM_BATCH_SIZE flake_id_config.prefetch_validity_in_millis = to_millis( SHORT_TERM_VALIDITY_SECONDS) config.add_flake_id_generator_config(flake_id_config) return config
def __init__(self, client, service_name, name): super(FlakeIdGenerator, self).__init__(client, service_name, name) config = client.config.flake_id_generator_configs.get(name, None) if config is None: config = FlakeIdGeneratorConfig() self._auto_batcher = _AutoBatcher(config.prefetch_count, config.prefetch_validity_in_millis, self._new_id_batch)
def setUp(self): self.flake_id_config = FlakeIdGeneratorConfig()