forked from uncloud/uncloud
meow
6fa77bce4d
Remove individual config.py used by every component and put them into single config.py ucloud/config.py Use /etc/ucloud/ucloud.conf for Environment Variables Refactoring and a lot of it Make ucloud repo a package and different components of ucloud a subpackage for avoiding code duplication. Improved logging.
21 lines
436 B
Python
21 lines
436 B
Python
from etcd3_wrapper import Etcd3Wrapper
|
|
|
|
|
|
def increment_etcd_counter(etcd_client: Etcd3Wrapper, key):
|
|
kv = etcd_client.get(key)
|
|
|
|
if kv:
|
|
counter = int(kv.value)
|
|
counter = counter + 1
|
|
else:
|
|
counter = 1
|
|
|
|
etcd_client.put(key, str(counter))
|
|
return counter
|
|
|
|
|
|
def get_etcd_counter(etcd_client: Etcd3Wrapper, key):
|
|
kv = etcd_client.get(key)
|
|
if kv:
|
|
return int(kv.value)
|
|
return None
|