浏览代码

update comments,README

yokyo 5 年之前
父节点
当前提交
a709c9785d
共有 5 个文件被更改,包括 41 次插入7 次删除
  1. 1 0
      .gitignore
  2. 17 3
      README.md
  3. 14 4
      build
  4. 7 0
      confs.proto
  5. 2 0
      logics/bitlegend.proto

+ 1 - 0
.gitignore

@@ -1 +1,2 @@
 *.pb.go
+*_pb2.py

+ 17 - 3
README.md

@@ -2,6 +2,14 @@
 
 protocol in protobuf3
 
+## 编译
+
+```shell
+build -h #查看帮助
+build -g #编译 golang
+build -p #编译 python
+build -c #清除编译后文件
+```
 ## 文件说明
 
 - modules 目录
@@ -13,7 +21,7 @@ protocol in protobuf3
 - login_internal.proto
 > 定义登录服务器和其他服务器的协议
 
-- main.proto
+- tajmahal.proto
 > 定义客户端和游戏服务器的协议
 
 - outline.proto
@@ -25,8 +33,14 @@ protocol in protobuf3
 - structs.proto
 > 定义子结构
 
-- enums.proto
+- enums*.proto
 > 定义 enum
 
 - logics 目录
-> 定义各个游戏逻辑的协议, 包括主游戏和将来的游戏内小游戏
+> 定义各个游戏逻辑的协议, 包括主游戏和将来的游戏内小游戏
+
+- errors.proto
+> 定义错误码,理想情况下,包含所有项目的所有错误码
+
+- confs.proto
+> 定义可重用的配置项目

+ 14 - 4
build

@@ -7,25 +7,35 @@ def main():
     parser = argparse.ArgumentParser()
     parser.add_argument('-g', '--golang', help='build proto to golang output', action='store_true')
     parser.add_argument('-p', '--python', help='build proto to python output', action='store_true')
+    parser.add_argument('-c', '--clean', help='clean build outputs', action='store_true')
     args = parser.parse_args()
     
-    if not args.golang and not args.python:
+    if not args.golang and not args.python and not args.clean:
         args.golang = True
 
+    cleaned = []
     for cur, dirs, files in os.walk('.'):
         if cur[2:8] == 'google':
             continue
+        if cur[2:6] == '.git':
+            continue
         for file in files:
             f, ext = os.path.splitext(file)
             if ext != '.proto':
                 continue
+            
             if args.golang:
+                print('building ', file, ' golang ...')
                 os.system('protoc --go_out=. {}'.format(os.path.join(cur,file)))
             if args.python:
+                print('building ', file, ' python ...')
                 os.system('protoc --python_out=. {}'.format(os.path.join(cur, file)))
-            print('.')
-
+        if args.clean and cur not in cleaned:
+            print('removing ', cur, '...')
+            os.system('rm {0}/*.pb.go {0}/*_pb2.py'.format(cur))
+            cleaned.append(cur)
+    if args.golang or args.python:
+        print('done. check if any errors.')
 
 if __name__ == '__main__':
     main()
-    print('done. check if any errors.')

+ 7 - 0
confs.proto

@@ -5,6 +5,7 @@ import "structs.proto";
 
 // 项目中配置文件定义
 
+// zookeeper 连接配置
 message ZkConf {
     repeated string addrs   = 1;
     string username         = 2;
@@ -12,12 +13,14 @@ message ZkConf {
     int32 timeout           = 4;
 }
 
+// redis 连接配置
 message RedisConf {
     repeated string addrs   = 1;
     string password         = 2;
     int32 db                = 3;
 }
 
+// nats(-streaming) 连接配置
 message NatsConf {
     repeated string addrs   = 1;
     string username         = 2;
@@ -25,6 +28,7 @@ message NatsConf {
     string clusterId        = 4;
 }
 
+// agent 服务器配置
 message AgentConf {
     ZkConf zoo          = 1;
     string namespace    = 2;
@@ -44,6 +48,8 @@ message LoginZkConf {
     string password         = 2;
 }
 
+// login 服务器启动配置
+// 因为 login 不在 zookeeper 中注册服务,所以 login 有两个配置
 message LoginConf {
     uint64 id           = 1;
     RedisConf redis     = 2;
@@ -92,6 +98,7 @@ message RouteRules {
     repeated RouteRule_ rules = 1;
 }
 
+// smtp 服务器配置
 message EmailConf {
     string smtp     = 1;
     int32 port      = 2;

+ 2 - 0
logics/bitlegend.proto

@@ -0,0 +1,2 @@
+syntax="proto3";
+package protos;