forked from p93542168/wheat-cache
feat(shell): add gen aof codec
This commit is contained in:
parent
3bcd154177
commit
27542cf898
|
@ -8,6 +8,7 @@ protoAddress = f"{sysPath}/protobuf"
|
||||||
tempPath = f"{sysPath}/storage/temp"
|
tempPath = f"{sysPath}/storage/temp"
|
||||||
daoPath = f"{sysPath}/storage/dao"
|
daoPath = f"{sysPath}/storage/dao"
|
||||||
servicePath = f"{sysPath}/storage/service"
|
servicePath = f"{sysPath}/storage/service"
|
||||||
|
aofPath = f"{sysPath}/storage/persisted"
|
||||||
|
|
||||||
|
|
||||||
class ProtoOption(object):
|
class ProtoOption(object):
|
||||||
|
@ -133,16 +134,33 @@ def gen_single_service(proto):
|
||||||
with open(temp_path, 'w', encoding='utf-8') as f:
|
with open(temp_path, 'w', encoding='utf-8') as f:
|
||||||
f.write(text)
|
f.write(text)
|
||||||
|
|
||||||
|
def gen_aof(proto):
|
||||||
|
tem_text = load_template("aof.template")
|
||||||
|
template = Template(tem_text)
|
||||||
|
|
||||||
|
text = template.render(keys=proto)
|
||||||
|
|
||||||
|
temp_path = f"{aofPath}/codec.gen.go"
|
||||||
|
with open(temp_path, 'w', encoding='utf-8') as f:
|
||||||
|
f.write(text)
|
||||||
|
|
||||||
def format_code_go():
|
def format_code_go():
|
||||||
go_fmt(f"{daoPath}/interface.gen.go")
|
go_fmt(f"{daoPath}/interface.gen.go")
|
||||||
go_fmt(f"{servicePath}/single_service.gen.go")
|
go_fmt(f"{servicePath}/single_service.gen.go")
|
||||||
|
go_fmt(f"{aofPath}/codec.gen.go")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# 加载 protobuf
|
# 加载 protobuf
|
||||||
protobuf = load_protobuf()
|
protobuf = load_protobuf()
|
||||||
|
|
||||||
# 生成 dao 接口
|
# 生成 dao 接口
|
||||||
gen_dao_interface(protobuf)
|
gen_dao_interface(protobuf)
|
||||||
|
|
||||||
|
# 生成服务代码
|
||||||
gen_single_service(protobuf)
|
gen_single_service(protobuf)
|
||||||
|
|
||||||
|
# 生成 aof 解码方案
|
||||||
|
gen_aof(protobuf)
|
||||||
format_code_go()
|
format_code_go()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in New Issue