demo.proto 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. syntax = "proto3";
  2. package live.livedemo.v1;
  3. option go_package = "v1";
  4. import "github.com/gogo/protobuf/gogoproto/gogo.proto";
  5. import "google/api/annotations.proto";
  6. // Foo 相关服务
  7. service Foo {
  8. // 根据uid得到uname
  9. // `method:"post" midware:"auth,verify"`
  10. //
  11. // 这是详细说明
  12. rpc uname_by_uid (Bar1Req) returns (Bar1Resp) {
  13. option (google.api.http) = {
  14. get:"/xlive/demo/v1/foo/uname_by_uid_custom_route"
  15. };
  16. };
  17. // 获取房间信息
  18. // `midware:"guest"`
  19. rpc get_info (GetInfoReq) returns (GetInfoResp);
  20. // 根据uid得到uname v3
  21. rpc uname_by_uid3 (Bar1Req) returns (Bar1Resp);
  22. // test comment
  23. // `internal:"true"`
  24. rpc uname_by_uid4 (Bar1Req) returns (Bar1Resp);
  25. // `dynamic_resp:"true"`
  26. rpc get_dynamic (Bar1Req) returns (Bar1Resp);
  27. // `dynamic:"true"`
  28. rpc nointerface (Bar1Req) returns (Bar1Resp);
  29. }
  30. service Foo2 {
  31. rpc hello (Bar1Req) returns (Bar1Resp);
  32. }
  33. // Bar请求
  34. message Bar1Req {
  35. // 用户uid
  36. //
  37. // aaa
  38. int32 uid = 1 [(gogoproto.moretags) = 'form:"uid"'];
  39. }
  40. // Bar 相应
  41. message Bar1Resp {
  42. // 用户名
  43. // `mock:"hello"`
  44. string uname = 2 [(gogoproto.jsontag) = "uname"];
  45. // idshaha
  46. // `mock:"343242"`
  47. repeated int32 ids = 3 [(gogoproto.jsontag) = "ids"];
  48. repeated List list = 4 [(gogoproto.jsontag) = "list"];
  49. List alist = 5 [(gogoproto.jsontag) = "alist"];
  50. message List {
  51. // `mock:"\"withquote"`
  52. string hello = 1 [(gogoproto.jsontag) = "hello"];
  53. string world = 2 [(gogoproto.jsontag) = "world"];
  54. }
  55. map<string, List> amap = 6 [(gogoproto.jsontag) = "amap"];
  56. }
  57. // 获取房间信息请求
  58. message GetInfoReq {
  59. // 房间id
  60. // `mock:"123"
  61. int64 room_id = 1 [(gogoproto.moretags) = 'form:"room_id" validate:"required"'];
  62. repeated int64 many_ids = 2 [(gogoproto.moretags) = 'form:"many_ids"'];
  63. }
  64. // 获取房间信息响应
  65. message GetInfoResp {
  66. // 房间id 注释貌似只有放在前面才能被识别,放到字段声明后面是没用的
  67. int64 roomid = 1 [(gogoproto.jsontag) = "roomid"]; // 这段注释不会被理会
  68. // 用户名
  69. string uname = 2 [(gogoproto.jsontag) = "uname"];
  70. // 开播时间
  71. string live_time = 3 [(gogoproto.jsontag) = "live_time"];
  72. map<int32, string> amap = 4 [(gogoproto.jsontag) = "amap"];
  73. // `mock:"6.02214129e23"`
  74. float rate = 5 [(gogoproto.jsontag) = "rate"];
  75. // 用户mid
  76. int64 mid = 6 [(gogoproto.jsontag) = "mid"];
  77. }