feat(shell): update shell

This commit is contained in:
bandl 2021-09-25 23:37:24 +08:00
parent eb53a976e2
commit 175bddf527
3 changed files with 6 additions and 9 deletions

View File

@ -8,7 +8,7 @@ import "gitee.com/timedb/wheatCache/pkg/proto"
type KeyBaseInterface interface {
SizeByte() int64
// TODO RollBack 事务相关, V2 实现
// RollBack TODO 事务相关, V2 实现
RollBack() error
// Begin 事务相关, V2 实现
Begin() error
@ -22,7 +22,7 @@ type KeyBaseInterface interface {
type {{key}}Interface interface{
KeyBaseInterface
{% for val in value -%}
{{val}}(*proto.{{val}}Request) (*ResultConn, error)
{{val}}(*proto.{{val}}Request) (*proto.{{val}}Response, error)
{% endfor %}
}
{% endfor -%}

View File

@ -28,9 +28,7 @@ def load_conf():
return cfg, cfg_camel
'''生成对应的数据结构proto文件'''
# 生成对应的数据结构proto文件
def mk_structure(cfg_camel):
path = "protobuf"
storagePath = f"{protobufPath}/storage.proto"
@ -59,8 +57,8 @@ def mk_structure(cfg_camel):
if flag == 0:
file = open(proto_path, 'a')
file.write('\nmessage ' + v + 'Request ' + '{\n BaseKey key = 1;\n}\n')
file.write("\nmessage %sResponse {\n int64 update_size = 1;\n}\n" % v)
file.close()
flag = 0
print(f"{key}.proto", "-> success")
@ -72,10 +70,10 @@ def mk_storage(cfg_camel):
'// Code generated by gen-struct. DO NOT EDIT.\n// make gen-protobuf generated\n\nsyntax = "proto3";\n\noption go_package = "pkg/proto";\n\n')
for key, value in cfg_camel.items():
file.write('import "' + key + '.proto";\n')
file.write('\nmessage CommendResponse {\n repeated string result = 1;\n}\n\nservice CommServer {\n')
file.write('\n\nservice CommServer {\n')
for key, value in cfg_camel.items():
for v in value:
file.write(' rpc ' + v + ' (' + v + 'Request) returns (CommendResponse);\n')
file.write(' rpc ' + v + ' (' + v + 'Request) returns (%s);\n' % "{}Response".format(v))
file.write('}')
file.close()
print("storage.proto", "-> success")

View File

@ -88,6 +88,5 @@ if __name__ == "__main__":
conf, cfg_camel = load_conf()
set_structure_const_template(conf)
set_structure_interface(cfg_camel)
# 格式化代码
format_code_go()