From 27542cf89801ca243913e5c7e2296bc6cb766ec3 Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Mon, 1 Nov 2021 17:35:59 +0800 Subject: [PATCH] feat(shell): add gen aof codec --- shell/make_service.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/shell/make_service.py b/shell/make_service.py index 8ab2ea2..83923d8 100644 --- a/shell/make_service.py +++ b/shell/make_service.py @@ -8,6 +8,7 @@ protoAddress = f"{sysPath}/protobuf" tempPath = f"{sysPath}/storage/temp" daoPath = f"{sysPath}/storage/dao" servicePath = f"{sysPath}/storage/service" +aofPath = f"{sysPath}/storage/persisted" class ProtoOption(object): @@ -133,16 +134,33 @@ def gen_single_service(proto): with open(temp_path, 'w', encoding='utf-8') as f: 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(): go_fmt(f"{daoPath}/interface.gen.go") go_fmt(f"{servicePath}/single_service.gen.go") + go_fmt(f"{aofPath}/codec.gen.go") def main(): # 加载 protobuf protobuf = load_protobuf() + # 生成 dao 接口 gen_dao_interface(protobuf) + + # 生成服务代码 gen_single_service(protobuf) + + # 生成 aof 解码方案 + gen_aof(protobuf) format_code_go() if __name__ == "__main__":