├── .github └── workflows │ └── cla.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CODE_OF_CONDUCT.zh_CN.md ├── CONTRIBUTING.md ├── CONTRIBUTING.zh_CN.md ├── CONTRIBUTORS.md ├── CONTRIBUTORS.zh_CN.md ├── LICENSE ├── Makefile ├── README.md ├── README.zh_CN.md ├── WORKSPACE ├── docs ├── en │ ├── architecture_design.md │ ├── plugin_ecosystem.md │ ├── terminology.md │ └── trpc_protocol_design.md ├── images │ ├── architecture.png │ ├── codec.png │ ├── filter.png │ ├── layer.png │ ├── multi_proto_multi_service_instance.png │ ├── naming.png │ ├── rpc.png │ ├── rpc_workflow.png │ ├── single_proto_multi_service_instance.png │ ├── single_proto_single_service_instance.png │ ├── trpc-protocol.png │ └── wireshark │ │ ├── pic1.png │ │ ├── pic10.png │ │ ├── pic2.png │ │ ├── pic3.png │ │ ├── pic4.png │ │ ├── pic5.png │ │ ├── pic6.png │ │ ├── pic7.png │ │ ├── pic8.png │ │ └── pic9.png └── zh │ ├── architecture_design.md │ ├── plugin_ecosystem.md │ ├── terminology.md │ ├── trpc_protocol_design.md │ └── wireshark_trpc.md ├── pb └── go │ └── trpc │ ├── api │ ├── annotations.pb.go │ ├── http.pb.go │ └── openapiv2.pb.go │ ├── go.mod │ ├── go.sum │ ├── proto │ └── trpc_options.pb.go │ ├── reflection │ └── reflection.pb.go │ ├── swagger │ └── swagger.pb.go │ ├── trpc.pb.go │ ├── v2 │ ├── api │ │ ├── annotations.pb.go │ │ └── http.pb.go │ ├── go.mod │ ├── go.sum │ ├── proto │ │ └── trpc_options.pb.go │ ├── swagger │ │ └── swagger.pb.go │ ├── trpc.pb.go │ └── validate │ │ └── validate.pb.go │ └── validate │ └── validate.pb.go ├── proposal ├── README.md ├── README.zh_CN.md ├── TEMPLATE.md └── TEMPLATE.zh_CN.md ├── test ├── BUILD ├── README.md └── cpp │ └── BUILD ├── testbuild.sh ├── tool └── wireshark_trpc.lua └── trpc ├── BUILD ├── api ├── BUILD ├── annotations.proto ├── http.proto └── openapiv2.proto ├── proto ├── BUILD └── trpc_options.proto ├── reflection ├── BUILD └── reflection.proto ├── swagger ├── BUILD └── swagger.proto ├── trpc.proto ├── v2 ├── BUILD ├── api │ ├── BUILD │ ├── annotations.proto │ └── http.proto ├── proto │ ├── BUILD │ └── trpc_options.proto ├── swagger │ ├── BUILD │ └── swagger.proto ├── trpc.proto └── validate │ ├── BUILD │ └── validate.proto └── validate ├── BUILD └── validate.proto /.github/workflows/cla.yml: -------------------------------------------------------------------------------- 1 | name: "CLA Assistant" 2 | on: 3 | issue_comment: 4 | types: [created] 5 | pull_request_target: 6 | types: [opened, synchronize, reopened] 7 | 8 | # explicitly configure permissions, in case your GITHUB_TOKEN workflow permissions are set to read-only in repository settings 9 | permissions: 10 | actions: write 11 | contents: write 12 | pull-requests: write 13 | statuses: write 14 | 15 | jobs: 16 | CLAAssistant: 17 | runs-on: ubuntu-latest 18 | steps: 19 | - name: "CLA Assistant" 20 | if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target' 21 | uses: contributor-assistant/github-action@v2.3.1 22 | env: 23 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 24 | PERSONAL_ACCESS_TOKEN: ${{ secrets.CLA_DATABASE_ACCESS_TOKEN }} 25 | with: 26 | remote-organization-name: trpc-group 27 | remote-repository-name: cla-database 28 | path-to-signatures: 'signatures/${{ github.event.repository.name }}-${{ github.repository_id }}/cla.json' 29 | path-to-document: 'https://github.com/trpc-group/cla-database/blob/main/Tencent-Contributor-License-Agreement.md' 30 | # branch should not be protected 31 | branch: 'main' 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | .idea/ 3 | 4 | bazel-* 5 | *.swp 6 | *.o 7 | *.log 8 | *.so 9 | *.a 10 | *.dylib 11 | 12 | CMakeCache.txt 13 | CMakeFiles 14 | CMakeScripts 15 | cmake_third_party/ 16 | cmake-build-debug/ 17 | 18 | build/ 19 | *.pb.h 20 | *.pb.cc 21 | 22 | ### PreCI ### 23 | .codecc -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | English | [中文](CODE_OF_CONDUCT.zh_CN.md) 2 | 3 | # Community Code of Conduct 4 | 5 | Welcome to our open source project! 6 | 7 | We are committed to creating a friendly, respectful, and inclusive community. 8 | To ensure a positive experience in our project, we have established the following code of conduct, which we require all participants to abide by, and provide a safe and inclusive environment for all community members. 9 | 10 | ## Our Pledge 11 | 12 | As participants, contributors, and maintainers of our community, we pledge to: 13 | - Treat everyone with openness, inclusivity, and collaboration; 14 | - Respect individuals with different backgrounds and viewpoints, regardless of gender, sexual orientation, disability, race, ethnicity, religion, age, or any other factor; 15 | - Focus on contributing and improving the project, rather than attacking or criticizing individuals; 16 | - Build trust with community members and promote our project through constructive feedback; 17 | - Provide a safe, supportive, and encouraging environment for community members to promote learning and personal growth. 18 | 19 | ## Our standards 20 | 21 | Our community members should adhere to the following standards: 22 | - Respect the opinions, viewpoints, and experiences of others; 23 | - Avoid using insulting, discriminatory, or harmful language; 24 | - Do not harass, intimidate, or threaten others; 25 | - Do not publicly or privately disclose others' private information, such as contact information or addresses; 26 | - Respect the privacy of others; 27 | - Establish a safe, inclusive, and respectful environment for community members. 28 | 29 | ## Our responsibility 30 | 31 | Project maintainers have a responsibility to create a friendly, respectful, and inclusive environment for our community members. 32 | They should: 33 | - Clearly and publicly explain the community guidelines; 34 | - Handle reports of guideline violations and resolve disputes appropriately; 35 | - Protect the privacy and security of all community members; 36 | - Maintain a fair, transparent, and responsible attitude. 37 | 38 | 39 | ## Scope 40 | 41 | This code of conduct applies to all project spaces, including GitHub, mailing lists, forums, social media, gatherings, and conferences. 42 | Violations of the code of conduct will be dealt with, including but not limited to warnings, temporary or permanent bans, revocation of contribution rights, and revocation of project access rights. 43 | 44 | ## Implementation guidelines 45 | 46 | If you encounter behavior that violates this code of conduct, you can: 47 | - Communicate privately with the relevant person to try to resolve the issue; 48 | - Report the violation to the project maintainers(maintainer mailing list), who will take necessary action based on the situation; 49 | - If you are not satisfied with the way the maintainers handle the situation, you can seek help from higher-level organizations or institutions. 50 | 51 | Our community is a diverse, open, and inclusive community, and we welcome everyone's participation and contribution. 52 | We believe that only in a safe, respectful, and inclusive environment can we create the best project together. 53 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.zh_CN.md: -------------------------------------------------------------------------------- 1 | [English](CODE_OF_CONDUCT.md) | 中文 2 | 3 | # 社区行为准则 4 | 5 | 欢迎来到我们的开源项目! 6 | 7 | 我们致力于创建一个友好、尊重和包容的社区,我们希望所有人都能为此做出贡献。 8 | 为了确保在我们的项目中有一个积极的体验,我们制定了以下行为准则,我们要求所有参与者遵守这些准则,并向所有社区成员提供一个安全和包容的环境。 9 | 10 | ## 我们的承诺 11 | 12 | 作为我们社区的参与者、贡献者和维护者,我们承诺: 13 | - 以开放、包容和合作的态度对待所有人; 14 | - 尊重不同背景和观点的人,不论是性别、性取向、残疾、种族、民族、宗教、年龄或任何其他因素; 15 | - 专注于对项目的贡献和改进,而不是对个人的攻击或抨击; 16 | - 与社区成员建立互信关系,通过积极的反馈来推动我们的项目发展; 17 | - 为社区成员提供一个安全、支持和鼓励的环境,以促进学习和个人成长。 18 | 19 | ## 我们的标准 20 | 21 | 我们的社区成员应该遵守以下标准: 22 | - 尊重他人的意见、观点和经验; 23 | - 避免使用侮辱性、歧视性或有损的语言; 24 | - 不要骚扰、恐吓或威胁他人; 25 | - 不要公开或私下发布他人的私人信息,例如联系方式或地址; 26 | - 尊重他人的隐私权; 27 | - 为社区成员建立安全、包容和尊重的环境。 28 | 29 | ## 我们的责任 30 | 31 | 项目维护者有责任为我们的社区成员创造一个友好、尊重和包容的环境。 32 | 他们应该: 33 | - 明确和公开地说明社区准则; 34 | - 处理准则违规行为的举报,通过适当的方式解决纠纷; 35 | - 保护所有社区成员的隐私和安全; 36 | - 保持公正、透明和负责任的态度。 37 | 38 | ## 管理范围 39 | 40 | 本行为准则适用于所有的项目空间,包括GitHub、邮件列表、论坛、社交媒体、聚会和会议等。 41 | 违反准则的行为将受到处理,包括但不限于警告、暂时或永久禁言、撤销贡献权、撤销项目访问权等。 42 | 43 | ## 实施指南 44 | 45 | 如果你遇到了违反本准则的行为,你可以: 46 | - 私下与相关人员沟通,以尝试解决问题; 47 | - 向项目维护者报告违规行为,维护者会根据情况采取必要的行动; 48 | - 如果你不满意维护者的处理方式,你可以向更高级别的机构或组织寻求帮助。 49 | 50 | 我们的社区是一个多样化、开放和包容的社区,我们欢迎所有人的参与和贡献。 51 | 我们相信,只有在一个安全、尊重和包容的环境中,我们才能共同创造出最优秀的项目。 52 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | English | [中文](CONTRIBUTING.zh_CN.md) 2 | 3 | # How to Contribute 4 | 5 | Thank you for your interest and support in tRPC! 6 | 7 | We welcome and appreciate any form of contribution, including but not limited to submitting issues, providing improvement suggestions, improving documentation, fixing bugs, and adding features. 8 | This document aims to provide you with a detailed contribution guide to help you better participate in the project. 9 | Please read this guide carefully before contributing and make sure to follow the rules here. 10 | We look forward to working with you to make this project better together! 11 | 12 | ## Before contributing code 13 | 14 | The project welcomes code patches, but to make sure things are well coordinated you should discuss any significant change before starting the work. 15 | It's recommended that you signal your intention to contribute in the issue tracker, either by claiming an [existing one](https://github.com/trpc-group/trpc/issues) or by [opening a new issue](https://github.com/trpc-group/trpc/issues/new). 16 | 17 | ### Checking the issue tracker 18 | 19 | Whether you already know what contribution to make, or you are searching for an idea, the [issue tracker](https://github.com/trpc-group/trpc/issues) is always the first place to go. 20 | Issues are triaged to categorize them and manage the workflow. 21 | 22 | Most issues will be marked with one of the following workflow labels: 23 | - **NeedsInvestigation**: The issue is not fully understood and requires analysis to understand the root cause. 24 | - **NeedsDecision**: The issue is relatively well understood, but the tRPC team hasn't yet decided the best way to address it. 25 | It would be better to wait for a decision before writing code. 26 | If you are interested in working on an issue in this state, feel free to "ping" maintainers in the issue's comments if some time has passed without a decision. 27 | - **NeedsFix**: The issue is fully understood and code can be written to fix it. 28 | 29 | ### Opening an issue for any new problem 30 | 31 | Excluding very trivial changes, all contributions should be connected to an existing issue. 32 | Feel free to open one and discuss your plans. 33 | This process gives everyone a chance to validate the design, helps prevent duplication of effort, and ensures that the idea fits inside the goals for the language and tools. 34 | It also checks that the design is sound before code is written; the code review tool is not the place for high-level discussions. 35 | 36 | When opening an issue, make sure to answer these five questions: 37 | 1. What version of tRPC are you using ? 38 | 2. What operating system and compiler are you using? 39 | 3. What did you do? 40 | 4. What did you expect to see? 41 | 5. What did you see instead? 42 | 43 | For change proposals, see Proposing Changes To [tRPC-Proposals](https://github.com/trpc-group/trpc/blob/main/proposal/README.md). 44 | 45 | ## Contributing code 46 | 47 | Follow the [GitHub flow](https://docs.github.com/en/get-started/quickstart/github-flow) to [create a GitHub pull request](https://docs.github.com/en/get-started/quickstart/github-flow#create-a-pull-request). 48 | 49 | If this is your first time submitting a PR to the tRPC project, you will be reminded in the "Conversation" tab of the PR to sign and submit the [Contributor License Agreement](https://github.com/trpc-group/cla-database/blob/main/Tencent-Contributor-License-Agreement.md). 50 | Only when you have signed the Contributor License Agreement, your submitted PR has the possibility of being accepted. 51 | 52 | 53 | Some things to keep in mind: 54 | - Ensure that your code conforms to the project's code specifications. 55 | This includes but is not limited to code style, comment specifications, etc. This helps us to maintain the cleanliness and consistency of the project. 56 | - Before submitting a PR, please make sure that you have tested your code locally(`bazel test //trpc/...`). 57 | Ensure that the code has no obvious errors and can run normally. 58 | - To update the pull request with new code, just push it to the branch; 59 | you can either add more commits, or rebase and force-push (both styles are accepted). 60 | - If the request is accepted, all commits will be squashed, and the final commit description will be composed by concatenating the pull request's title and description. 61 | The individual commits' descriptions will be discarded. 62 | See following "Write good commit messages" for some suggestions. 63 | 64 | ### Writing good commit messages 65 | 66 | Commit messages in tRPC follow a specific set of conventions, which we discuss in this section. 67 | 68 | Here is an example of a good one: 69 | 70 | 71 | > math: improve Sin, Cos and Tan precision for very large arguments 72 | > 73 | > The existing implementation has poor numerical properties for 74 | > large arguments, so use the McGillicutty algorithm to improve 75 | > accuracy above 1e10. 76 | > 77 | > The algorithm is described at https://wikipedia.org/wiki/McGillicutty_Algorithm 78 | > 79 | > Fixes #159 80 | 81 | 82 | #### First line 83 | 84 | The first line of the change description is conventionally a short one-line summary of the change, prefixed by the primary affected package. 85 | 86 | A rule of thumb is that it should be written so to complete the sentence "This change modifies tRPC to _____." 87 | That means it does not start with a capital letter, is not a complete sentence, and actually summarizes the result of the change. 88 | 89 | Follow the first line by a blank line. 90 | 91 | #### Main content 92 | 93 | The rest of the description elaborates and should provide context for the change and explain what it does. 94 | Write in complete sentences with correct punctuation, just like for your comments in tRPC. 95 | Don't use HTML, Markdown, or any other markup language. 96 | Add any relevant information, such as benchmark data if the change affects performance. 97 | 98 | #### Referencing issues 99 | 100 | The special notation "Fixes #12345" associates the change with issue 12345 in the tRPC issue tracker. 101 | When this change is eventually applied, the issue tracker will automatically mark the issue as fixed. 102 | 103 | 104 | ## Miscellaneous topics 105 | 106 | ### Copyright headers 107 | 108 | Files in the tRPC repository don't list author names, both to avoid clutter and to avoid having to keep the lists up to date. 109 | Instead, your name will appear in the change log. 110 | 111 | New files that you contribute should use the standard copyright header: 112 | 113 | ```cpp 114 | // 115 | // 116 | // Tencent is pleased to support the open source community by making tRPC available. 117 | // 118 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 119 | // All rights reserved. 120 | // 121 | // If you have downloaded a copy of the tRPC source code from Tencent, 122 | // please note that tRPC source code is licensed under the Apache 2.0 License, 123 | // A copy of the Apache 2.0 License is included in this file. 124 | // 125 | // 126 | ``` 127 | 128 | Files in the repository are copyrighted the year they are added. 129 | Do not update the copyright year on files that you change. 130 | -------------------------------------------------------------------------------- /CONTRIBUTING.zh_CN.md: -------------------------------------------------------------------------------- 1 | [English](CONTRIBUTING.md) | 中文 2 | 3 | # 如何贡献 4 | 5 | 感谢您对 tRPC 的关注和支持! 6 | 7 | 我们欢迎并感激任何形式的贡献,包括但不限于提交 issue、提供改进建议、改进文档、修复错误和添加功能。 8 | 本文档旨在为您提供详细的贡献指南,以帮助您更好地参与项目。 9 | 在贡献之前,请仔细阅读本指南并确保遵循这里的规则。 10 | 我们期待与您共同努力,使这个项目变得更好! 11 | 12 | ## 在贡献代码之前 13 | 14 | 项目欢迎代码补丁,但为了确保事情得到良好协调,您应该在开始工作之前讨论任何重大变更。 15 | 建议您在 issue 跟踪器中表明您的贡献意图,可以通过[认领现有 issue](https://github.com/trpc-group/trpc/issues)或[创建新 issue](https://github.com/trpc-group/trpc/issues/new) 来实现。 16 | 17 | ### 查看 issue 跟踪器 18 | 19 | 无论您已经知道要做哪些贡献,还是正在寻找想法,[issue 跟踪器](https://github.com/trpc-group/trpc/issues)始终是您的第一个去处。 20 | issue 会被分类以管理工作流程。 21 | 22 | 大多数 issue 都会被标记为以下工作流标签之一: 23 | - **NeedsInvestigation**:issue 尚未完全理解,需要分析以了解根本原因。 24 | - **NeedsDecision**:issue 相对已经理解得很好,但tRPC团队尚未决定解决 issue 的最佳方法。 25 | 在编写代码之前最好等待决策。 26 | 如果一段时间内没有决策且您有兴趣处理处于这种状态的 issue,请随时在 issue 评论中“ping”维护者。 27 | - **NeedsFix**:issue 已完全理解,可以编写代码进行修复。 28 | 29 | ### 为任何新问题打开一个 issue 30 | 31 | 除非是非常细小的变更,否则所有贡献都应与现有 issue 有关。 32 | 请随时打开一个 issue 并讨论您的计划。 33 | 这个过程让每个人都有机会验证设计,有助于防止工作重复,确保想法符合语言和工具的目标。 34 | 在编写代码之前,还可以检查设计是否合理;代码审查工具并非用于高层次的讨论。 35 | 36 | 在提交 issue 时,请确保回答以下五个问题: 37 | 1. 您正在使用哪个版本的tRPC? 38 | 2. 您正在使用哪个操作系统和编译器? 39 | 3. 您做了什么? 40 | 4. 您期望看到什么? 41 | 5. 您实际看到的是什么? 42 | 43 | 关于变更提案,请参阅向 [tRPC-Proposals](https://github.com/trpc-group/trpc/blob/main/proposal/README.zh_CN.md) 提议变更。 44 | 45 | ## 贡献代码 46 | 47 | 遵循 [GitHub 流程](https://docs.github.com/en/get-started/quickstart/github-flow)来[创建 GitHub PR(Pull Request)](https://docs.github.com/en/get-started/quickstart/github-flow#create-a-pull-request)。 48 | 49 | 如果你是第一次向 tRPC 项目提交 PR,那么在该 PR 的对话栏中会提醒你签署并提交[贡献者许可协议](https://github.com/trpc-group/cla-database/blob/main/Tencent-Contributor-License-Agreement.md)。 50 | 只有当你签署过贡献者许可协议,你提交的 PR 才有可能被接受。 51 | 请记住以下几点: 52 | 53 | - 确保您的代码符合项目的代码规范。 54 | 这包括但不限于代码风格、注释规范等。这有助于我们维护项目的整洁性和一致性。 55 | - 在提交 PR 之前,请确保您已在本地测试过您的代码。 确保代码没有明显的错误并且可以正常运行。 56 | - 要使用新代码更新拉取请求,只需将其推送到分支; 您可以添加更多提交,也可以 rebase 并 force-push(两种风格都可以接受)。 57 | - 如果请求被接受,所有提交将被压缩,最终提交描述将由 PR 的标题和描述组成。 58 | 单个提交的描述将被丢弃。 请参阅以下“编写良好的提交消息”以获取一些建议。 59 | 60 | ### 编写良好的提交消息 61 | 62 | tRPC 中的提交消息遵循一套特定的约定,我们将在本节中讨论。 63 | 64 | 以下是一个良好的示例: 65 | > math: improve Sin, Cos and Tan precision for very large arguments 66 | > 67 | > The existing implementation has poor numerical properties for large arguments, so use the McGillicutty algorithm to improve accuracy above 1e10. 68 | > 69 | > The algorithm is described at https://wikipedia.org/wiki/McGillicutty_Algorithm 70 | > 71 | > Fixes #159 72 | 73 | #### 第一行 74 | 75 | 变更描述的第一行通常是一个简短的一行摘要,描述变更的内容,并以主要受影响的包为前缀。 76 | 77 | 一个经验法则是,它应该被写成完成句子 "This change modifies tRPC to _____." 这意味着它不以大写字母开头,不是一个完整的句子,而且确实概括了变更的结果。 78 | 79 | 在第一行之后空一行。 80 | 81 | #### 主要内容 82 | 83 | 描述的其余部分应该详细说明,为变更提供上下文并解释它的作用。 84 | 像在 tRPC 中的注释一样,使用正确的标点符号写完整的句子。 85 | 不要使用 HTML、Markdown 或任何其他标记语言。 86 | 添加任何相关信息,例如如果变更影响性能,请添加基准数据。 87 | 88 | #### 引用 issue 89 | 90 | 特殊表示法 "Fixes #12345" 将变更与 tRPC issue 跟踪器中的 issue 12345关联。 91 | 当此变更最终应用时,issue 跟踪器将自动将该 issue 标记为已修复。 92 | 93 | ## 其他主题 94 | 95 | ### 版权声明 96 | 97 | tRPC 代码仓库中的文件不列出作者姓名,以避免混乱并避免不断更新列表。 98 | 而您的名字将出现在变更日志中。 99 | 100 | 您贡献的新文件应使用标准版权声明: 101 | ```cpp 102 | // 103 | // 104 | // Tencent is pleased to support the open source community by making tRPC available. 105 | // 106 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 107 | // All rights reserved. 108 | // 109 | // If you have downloaded a copy of the tRPC source code from Tencent, 110 | // please note that tRPC source code is licensed under the Apache 2.0 License, 111 | // A copy of the Apache 2.0 License is included in this file. 112 | // 113 | // 114 | ``` 115 | 116 | 代码仓库中的文件在添加时受版权保护。 117 | 在变更文件时,请勿更新版权年份。 118 | -------------------------------------------------------------------------------- /CONTRIBUTORS.md: -------------------------------------------------------------------------------- 1 | English | [中文](CONTRIBUTORS.zh_CN.md) 2 | 3 | # Contributor Guidelines 4 | 5 | Thank you for your interest and support for tRPC! 6 | This document outlines the roles and responsibilities of contributors in the project, as well as the process for becoming a Contributor and losing Maintainer status. We hope that this document will help every contributor understand the growth path and make a greater contribution to the project's development. 7 | 8 | ## Contributor Roles and Responsibilities 9 | 10 | we have two main contributor roles: Contributor and Maintainer. 11 | Here is a brief introduction to these two roles: 12 | 1. Contributor: A contributor to the project who can contribute code, documentation, testing, and other resources. Contributors provide valuable resources to the project, helping it to continuously improve and develop. 13 | 2. Maintainer: A maintainer of the project who is responsible for the day-to-day maintenance of the project, including reviewing and merging PRs, handling issues, and releasing versions. Maintainers are key members of the project and have a significant impact on the project's development direction and decision-making. 14 | 15 | ## How to become a Maintainer 16 | 17 | We welcome every contributor to contribute to the project's development and encourage contributors to upgrade to the role of Maintainer. 18 | The following are the conditions for upgrading from Contributor to Maintainer: 19 | 1. Continuous contribution: Contributors need to contribute to the project continuously for a period of time (e.g., 3 months). This demonstrates the contributor's attention and enthusiasm for the project. 20 | 2. Quality assurance: The code or documentation submitted by contributors needs to maintain a high level of quality, meet the project's specifications, and have a positive impact on the project. 21 | 3. Active participation: Contributors need to actively participate in project discussions and decision-making, providing constructive opinions and suggestions for the project's development. 22 | 4. Team collaboration: Contributors need to have good teamwork skills, communicate friendly with other contributors and maintainers, and work together to solve problems. 23 | 5. Responsibility: Contributors need to have a certain sense of responsibility and be willing to undertake some of the project maintenance work, including reviewing PRs and handling issues. When a contributor meets the above conditions, existing maintainers will evaluate them. 24 | 25 | If they meet the requirements of Maintainer, they will be invited to become a new Maintainer. 26 | 27 | ## Losing Maintainers status 28 | 29 | Maintainer have important responsibilities in the project, and we hope that every Maintainer can maintain their attention and enthusiasm for the project. 30 | However, we also understand that everyone's time and energy are limited, so when Maintainers cannot continue to fulfill their responsibilities, they will be downgraded to the role of Contributor: 31 | 1. Long-term inactivity: If a Maintainer has not participated in project maintenance work, including reviewing PRs and handling issues, for a period of time (e.g., 3 months), they will be considered inactive. 32 | 2. Quality issues: If a Maintainer's work in the project has serious quality issues that affect the project's development, they will be considered not meeting the requirements of Maintainer. 33 | 3. Team collaboration issues: If a Maintainer has serious communication or teamwork issues with other contributors and maintainers, such as disrespecting others' opinions, frequent conflicts, or refusing to collaborate, which affects the project's normal operation and atmosphere, they will be considered not meeting the requirements of Maintainer. 34 | 4. Violation of rules: If a Maintainer violates the project's rules or code of conduct, including but not limited to leaking sensitive information or abusing privileges, they will be considered not meeting the requirements of Maintainer. 35 | 5. Voluntary application: If a Maintainer cannot continue to fulfill their responsibilities due to personal reasons, they can voluntarily apply to be downgraded to the role of Contributor. 36 | -------------------------------------------------------------------------------- /CONTRIBUTORS.zh_CN.md: -------------------------------------------------------------------------------- 1 | [English](CONTRIBUTORS.md) | 中文 2 | 3 | # 贡献者管理说明文档 4 | 5 | 感谢您对本开源项目的关注和支持!本文档将阐述贡献者在项目中的角色、职责以及如何从Contributor升级为Maintainer,以及Maintainer降级为Contributor的规则。我们希望通过这份文档,让每位贡献者都能清楚地了解自己的成长路径,并为项目的发展做出更大的贡献。 6 | 7 | ## 贡献者角色及职责 8 | 9 | 在本开源项目中,我们主要设有两个贡献者角色:Contributor和Maintainer。 10 | 以下是对这两个角色的简要介绍: 11 | 1. Contributor:项目的贡献者,可以是代码贡献者、文档贡献者、测试贡献者等。Contributor为项目提供了宝贵的资源,帮助项目不断完善和发展。 12 | 2. Maintainer:项目的维护者,负责项目的日常维护工作,包括审查和合并PR、处理Issue、发布版本等。Maintainer是项目的核心成员,对项目的发展方向和决策具有重要的影响力。 13 | 14 | ## Contributor升级为Maintainer 15 | 16 | 我们非常欢迎每位Contributor为项目的发展做出贡献,并鼓励Contributor向Maintainer的角色发展。 17 | 以下是从Contributor升级为Maintainer的条件: 18 | 1. 持续贡献:Contributor需要在一段时间内(例如3个月)持续为项目贡献代码、文档或其他资源。这表明Contributor对项目的关注度和热情。 19 | 2. 质量保证:Contributor提交的代码或文档等资源需要保持较高的质量,符合项目的规范要求,并对项目产生积极的影响。 20 | 3. 积极参与:Contributor需要积极参与到项目的讨论和决策中来,为项目的发展提供建设性的意见和建议。 21 | 4. 团队协作:Contributor需要具备良好的团队协作精神,能够与其他贡献者和Maintainer友好沟通,共同解决问题。 22 | 5. 责任担当:Contributor需要具备一定的责任心,愿意承担项目维护的部分工作,包括审查PR、处理Issue等。 23 | 24 | 当Contributor满足以上条件时,现有的Maintainer将会对其进行评估,如果达到Maintainer的要求,将会邀请其成为新的Maintainer。 25 | 26 | ## Maintainer降级为Contributor 27 | 28 | Maintainer在项目中承担了重要的职责,我们希望每位Maintainer都能够保持对项目的关注和热情。 29 | 然而,我们也理解每个人的时间和精力是有限的,因此,当Maintainer无法继续履行职责时,将会降级为Contributor: 30 | 1. 长时间不活跃:如果Maintainer在一段时间内(例如3个月)没有参与项目的维护工作,包括审查PR、处理Issue等,将被视为不活跃。 31 | 2. 质量问题:如果Maintainer在项目中的工作出现严重的质量问题,导致项目的发展受到影响,将被视为不符合Maintainer的要求。 32 | 3. 团队协作问题:如果Maintainer在与其他贡献者和Maintainer的协作过程中出现严重的沟通问题或团队协作问题,如不尊重他人意见、频繁产生冲突、拒绝协作等,影响到项目的正常运作和氛围,将被视为不符合Maintainer的要求。 33 | 4. 违反规定:如果Maintainer违反了项目的规定或行为准则,包括但不限于泄露敏感信息、滥用权限等,将被视为不符合Maintainer的要求。 34 | 5. 主动申请:如果Maintainer由于个人原因无法继续履行职责,可以主动申请降级为Contributor。 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved. The below software in this distribution may have been modified by THL A29 Limited ("Tencent Modifications"). 2 | All Tencent Modifications are Copyright (C) THL A29 Limited. 3 | 4 | tRPC is licensed under the Apache License Version 2.0 except for the third-party components listed below. 5 | 6 | Apache License 7 | 8 | Version 2.0, January 2004 9 | 10 | http://www.apache.org/licenses/ 11 | 12 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 13 | 1. Definitions. 14 | 15 | "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. 16 | 17 | "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. 18 | 19 | "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. 20 | 21 | "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. 22 | 23 | "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. 24 | 25 | "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. 26 | 27 | "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). 28 | 29 | "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. 30 | 31 | "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." 32 | 33 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 34 | 35 | 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 36 | 37 | 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 38 | 39 | 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: 40 | 41 | You must give any other recipients of the Work or Derivative Works a copy of this License; and 42 | 43 | You must cause any modified files to carry prominent notices stating that You changed the files; and 44 | 45 | You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and 46 | 47 | If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. 48 | 49 | You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 50 | 51 | 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 52 | 53 | 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 54 | 55 | 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 56 | 57 | 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 58 | 59 | 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. 60 | 61 | END OF TERMS AND CONDITIONS 62 | 63 | 64 | Other dependencies and licenses: 65 | 66 | Open Source Software Licensed under the BSD 3-Clause License and Other Licenses of the Third-Party Components therein: 67 | -------------------------------------------------------------------- 68 | 1. protobuf 69 | Copyright (C) 2008 Google Inc. All rights reserved. 70 | 71 | 72 | A copy of the BSD 3-Clause License is included in this file. 73 | 74 | For the license of other third party components, please refer to the following URL: 75 | https://github.com/protocolbuffers/protobuf/tree/v3.15.8/third_party 76 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | DIR=pb/go 2 | INCLUDE_GOOGLE_PB_PATH=/usr/local/include 3 | all: 4 | rm -rf $(DIR) 5 | mkdir -p $(DIR) 6 | protoc -I$(INCLUDE_GOOGLE_PB_PATH) -I.\ 7 | --go_out=paths=source_relative:./$(DIR) \ 8 | ./trpc/api/annotations.proto \ 9 | ./trpc/api/http.proto \ 10 | ./trpc/api/openapiv2.proto 11 | protoc -I$(INCLUDE_GOOGLE_PB_PATH) -I.\ 12 | --go_out=./$(DIR) \ 13 | ./trpc/trpc.proto \ 14 | ./trpc/proto/trpc_options.proto \ 15 | ./trpc/swagger/swagger.proto \ 16 | ./trpc/validate/validate.proto \ 17 | ./trpc/reflection/reflection.proto 18 | mv $(DIR)/trpc.group/trpc/trpc-protocol/pb/go/trpc/* $(DIR)/trpc 19 | rm -rf $(DIR)/trpc.group 20 | cd ./$(DIR)/trpc && go mod init trpc.group/trpc/trpc-protocol/$(DIR)/trpc && go mod tidy && cd - 21 | 22 | # trpc v2 23 | protoc -I$(INCLUDE_GOOGLE_PB_PATH) -I.\ 24 | --go_out=paths=source_relative:./$(DIR) \ 25 | ./trpc/v2/api/annotations.proto \ 26 | ./trpc/v2/api/http.proto 27 | protoc -I$(INCLUDE_GOOGLE_PB_PATH) -I.\ 28 | --go_out=./$(DIR) \ 29 | ./trpc/v2/trpc.proto \ 30 | ./trpc/v2/proto/trpc_options.proto \ 31 | ./trpc/v2/swagger/swagger.proto \ 32 | ./trpc/v2/validate/validate.proto 33 | mv $(DIR)/trpc.group/trpc/trpc-protocol/pb/go/trpc/v2/* $(DIR)/trpc/v2 34 | rm -rf $(DIR)/trpc.group 35 | cd ./$(DIR)/trpc/v2 && go mod init trpc.group/trpc/trpc-protocol/$(DIR)/trpc/v2 && go mod tidy && cd - 36 | 37 | .PHONY: test clean 38 | 39 | test: 40 | ./testbuild.sh 41 | 42 | clean: 43 | rm -rf $(DIR) 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | English | [中文](README.zh_CN.md) 2 | 3 | # tRPC - A multi-language, pluggable, high-performance RPC framework 4 | 5 | ## What is tRPC 6 | 7 | tRPC is a high-performance RPC framework that designed based on the concept of pluggable,the overall design follows the following principles: 8 | - Simple: Users develop service very simply based on the framework. 9 | - High-Performance: The performant of the framework can be applicable to massive scenario on the internet. 10 | - Pluggable: The framework is layered and modularized in architectural design and implementation, and each core module be pluggable and evolves independently. 11 | 12 | By using tRPC, you can: 13 | - Build services (tRPC/HTTP(s)/gRPC, etc.) with multiple ports that support multiple protocols (one port only support one protocol), and can handle client requests synchronously/asynchronously. 14 | - Access various protocol backend services (tRPC/HTTP(s)/gRPC, etc.) in a synchronous, asynchronous, and one-way. 15 | - Streaming RPC programming, currently supports tRPC streaming, gRPC streaming, HTTP streaming, etc., to implement streaming application services such as Push, File Upload/Download, and AI Serving. 16 | - Support various protocols and service governance systems, such as: customized protocols, various name-service/metrics systems/tracing systems/config-center systems/log system, etc., to facilitate service interoperability and operation. 17 | 18 | ## Features 19 | 20 | - Works across languages:Implements cross-language service communication based on Protocol Buffers. 21 | - Support multi-protocols:Supports multiple protocols and interoperates with different frameworks (such as gRPC). 22 | - Streaming RPC: Supports streaming RPC, which is better suited for various application scenarios such as large file upload/download, message push, AI speech recognition/video understanding, etc. 23 | - Rich plugin ecosystem: Provides a large number of plugins that docking to microservice components (such as Consul/Promethues/OpenTelemetry, etc.) to facilitate users to build their own service governance system. 24 | - Scalability: Based on the pluggable design of the framework, users can develop secondary to expand the framework capabilities, such as: parameter validation, authentication, log replay, etc. 25 | - Flow & Overload control: provides flow control and overload protection plugins in a variety of application scenarios to prevent services from being overloaded and unavailable due to burst traffic. 26 | 27 | ## Supported languages 28 | 29 | - [Cpp](https://github.com/trpc-group/trpc-cpp) 30 | - [Go](https://github.com/trpc-group/trpc-go) 31 | 32 | ## To start using tRPC 33 | 34 | Per-language quickstart guides and tutorials can be found in the [tRPC website](https://trpc.group/docs/) . Code examples are available in the examples directory. 35 | 36 | - tRPC 37 | - [architecture design](https://github.com/trpc-group/trpc/blob/main/docs/en/architecture_design.md) 38 | - [terminology](https://github.com/trpc-group/trpc/blob/main/docs/en/terminology.md) 39 | - [plugin ecosystem](https://github.com/trpc-group/trpc/blob/main/docs/en/plugin_ecosystem.md) 40 | - [trpc protocol](https://github.com/trpc-group/trpc/blob/main/docs/en/trpc_protocol_design.md) 41 | - tRPC-Cpp: 42 | - [quick start](https://github.com/trpc-group/trpc-cpp/blob/main/docs/en/quick_start.md) 43 | - [basic tutorial](https://github.com/trpc-group/trpc-cpp/blob/main/docs/en/basic_tutorial.md) 44 | - [user guide](https://github.com/trpc-group/trpc-cpp/tree/main/docs) 45 | - [examples](https://github.com/trpc-group/trpc-cpp/tree/main/examples) 46 | - tRPC-Go: 47 | - [quick start](https://github.com/trpc-group/trpc-go/blob/main/docs/quick_start.md) 48 | - [basic tutorial](https://github.com/trpc-group/trpc-go/blob/main/docs/basics_tutorial.md) 49 | - [user guide](https://github.com/trpc-group/trpc-go/tree/main/docs/README.md) 50 | - [examples](https://github.com/trpc-group/trpc-go/tree/main/examples) 51 | 52 | ## To start developing tRPC 53 | 54 | Contributions are welcome! 55 | 56 | Please read [How to contribute](https://github.com/trpc-group/trpc/blob/main/CONTRIBUTORS.md) which will guide you through the entire workflow of how to build the source code, how to run the tests, and how to contribute changes to the tRPC codebase. 57 | 58 | ## Feedback 59 | 60 | Report bugs, ask questions or give suggestions by [Issues](https://github.com/trpc-group/trpc/issues) -------------------------------------------------------------------------------- /README.zh_CN.md: -------------------------------------------------------------------------------- 1 | [English](README.md) | 中文 2 | 3 | # tRPC - 多语言、插件化、高性能的RPC开发框架 4 | 5 | ## tRPC是什么 6 | 7 | tRPC是基于插件化理念设计的一款支持多语言、高性能的RPC框架,整体设计遵循以下原则: 8 | - 简单:用户基于框架进行服务开发简单方便; 9 | - 高性能:框架具备高性能,能适用互联网海量访问场景; 10 | - 插件化:框架在架构设计和具体实现上进行分层和模块化,各个核心模块可拔插,并能够独立演进; 11 | 12 | 你可以使用它: 13 | - 搭建多个端口支持多个协议(一个端口只能对应一个协议)的服务(tRPC/HTTP(s)/gRPC等),并能同步/异步处理客户端请求; 14 | - 以同步、异步、单向的方式访问各种协议后端服务(tRPC/HTTP(s)/gRPC等),调用各种存储系统(redis等); 15 | - 流式RPC编程,目前支持tRPC流式、gRPC流式、HTTP流式等,实现类似Push、文件上传/下载、AI类等流式应用服务; 16 | - 插件化支持各种协议和对接服务治理系统,比如:开发自定义的协议、对接业务使用的各种名字服务/监控系统/调用链系统/配置系统/日志系统等,方便服务互通和服务运营; 17 | 18 | ## TRPC特点 19 | 20 | - 跨语言:基于Protocol Buffers来实现跨语言之间的服务通信; 21 | - 多通信协议:支持多种通信协议,能够与不同框架进行互通(比如gRPC); 22 | - 流式RPC:支持流式RPC,更好地适用于大文件上传/下载、消息Push、AI类语音识别/视频理解等多种应用场景; 23 | - 丰富插件生态:提供大量对接业界微服务组件的插件(比如Consul/Promethues/Opentelemetry等),方便用户构建适合自己的服务治理体系; 24 | - 可扩展性:基于框架插件化的设计,用户可以进行二次开发来扩展框架能力,比如:RPC请求参数校验、鉴权、请求录制等; 25 | - 流控和过载保护:提供多种应用场景下的流量控制和过载保护插件,防止服务因为访问突增造成过载而不可用; 26 | 27 | ## 支持语言 28 | 29 | - [Cpp](https://github.com/trpc-group/trpc-cpp) 30 | - [Go](https://github.com/trpc-group/trpc-go) 31 | 32 | ## 如何使用tRPC 33 | 34 | 可以在 [tRPC官网](https://trpc.group/docs/) 找到tRPC每个语言的快速入门、基础教程等学习资料,也可以到tRPC各个语言的仓库查看详细的用户指南文档和代码示例。 35 | 36 | - tRPC 37 | - [架构设计](https://github.com/trpc-group/trpc/blob/main/docs/zh/architecture_design.md) 38 | - [术语介绍](https://github.com/trpc-group/trpc/blob/main/docs/zh/terminology.md) 39 | - [插件生态](https://github.com/trpc-group/trpc/blob/main/docs/zh/plugin_ecosystem.md) 40 | - [tRPC协议](https://github.com/trpc-group/trpc/blob/main/docs/zh/trpc_protocol_design.md) 41 | - tRPC-Cpp: 42 | - [快速开始](https://github.com/trpc-group/trpc-cpp/blob/main/docs/zh/quick_start.md) 43 | - [基础教程](https://github.com/trpc-group/trpc-cpp/blob/main/docs/zh/basic_tutorial.md) 44 | - [用户指南](https://github.com/trpc-group/trpc-cpp/blob/main/docs/README.zh_CN.md) 45 | - [代码示例](https://github.com/trpc-group/trpc-cpp/tree/main/examples) 46 | - tRPC-Go: 47 | - [快速开始](https://github.com/trpc-group/trpc-go/blob/main/docs/quick_start.zh_CN.md) 48 | - [基础教程](https://github.com/trpc-group/trpc-go/blob/main/docs/basics_tutorial.zh_CN.md) 49 | - [用户指南](https://github.com/trpc-group/trpc-go/tree/main/docs/README.zh_CN.md) 50 | - [代码示例](https://github.com/trpc-group/trpc-go/tree/main/examples) 51 | 52 | ## 如何用wireshark分析tRPC协议 53 | 54 | 参考 [docs/zh/wireshark_trpc.md](docs/zh/wireshark_trpc.md)。 55 | 56 | ## 如何参与贡献 57 | 58 | 非常欢迎大家给tRPC做贡献! 59 | 60 | 建议您在为tRPC贡献之前, 先阅读一下 [如何参与贡献](https://github.com/trpc-group/trpc/blob/main/CONTRIBUTORS.zh_CN.md) , 它会指导你了解贡献代码的整个流程, 比如: 如何提PR/如何构建代码/如何运行单元测试等。 61 | 62 | ## 建议反馈 63 | 64 | * 欢迎在[Issues](https://github.com/trpc-group/trpc/issues)中提出bug、疑惑、修改建议。 -------------------------------------------------------------------------------- /WORKSPACE: -------------------------------------------------------------------------------- 1 | workspace(name = "trpc_protocol") 2 | 3 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 4 | 5 | http_archive( 6 | name = "com_google_protobuf", 7 | sha256 = "d0f5f605d0d656007ce6c8b5a82df3037e1d8fe8b121ed42e536f569dec16113", 8 | strip_prefix = "protobuf-3.14.0", 9 | urls = [ 10 | "https://mirrors.tencent.com/github.com/protocolbuffers/protobuf/archive/v3.14.0.tar.gz", 11 | "https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v3.14.0.tar.gz", 12 | "https://github.com/protocolbuffers/protobuf/archive/v3.14.0.tar.gz", 13 | ], 14 | ) 15 | 16 | load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") 17 | protobuf_deps() 18 | -------------------------------------------------------------------------------- /docs/en/architecture_design.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | This article introduces the background of tRPC, pluggable design, and overall architecture. 4 | 5 | # Background 6 | 7 | In the early days of the development of the Internet, business scenarios varied greatly and iterations were rapid. This results in more or less differences in the language technology stacks, development frameworks, communication protocols, service governance systems, operation and maintenance platforms, etc. used by their backend services. 8 | 9 | At the same time, with the development of cloud native technology, businesses are increasingly using open source technology and cloud components. Embracing cloud native has become a mainstream trend. 10 | 11 | The above situation also exists within Tencent, and because of its large scale and diverse business types, it is more difficult to solve and must be solved. tRPC was born in this context. 12 | 13 | # Pluggable Design 14 | 15 | It must not only be interconnected with the existing technology system, but also adapt to cloud native technology and develop rapidly. This requires that the development framework must be open and extensible. In order to achieve this goal, tRPC adopts pluggable design ideas in architectural design. 16 | 17 | The tRPC pluggable design ideas are as follows: 18 | 19 | First, tRPC layers and modularizes the entire framework, and abstracts the core functional modules into independent plugins. The framework is then responsible for the concatenation and assembly of these independent plugins to achieve the features that the framework wants to support. 20 | 21 | In terms of specific implementation, the following key technologies are used: 22 | 1. plugin factory based on interface mechanism; 23 | 2. filter based on AOP idea; 24 | 25 | ## Plugin Factory 26 | 27 | The overall implementation idea of the plugin factory is that the framework only defines the standard interface of the plugin and provides registration capabilities without specific implementation. When interoperating with external services or connecting with a certain service governance system, you only need to develop the corresponding specific plugins. 28 | 29 | For example: tRPC supports multiple protocols by defined a unified Codec. Different protocols only need to be implemented according to the Codec interface. 30 | 31 | ![codec](/docs/images/codec.png) 32 | 33 | For example: tRPC connects to different naming service systems by defined unified Registry and Selector abstract interfaces. When connecting to different naming service systems, you only need to follow the Registry and Selector interfaces to implement it. 34 | 35 | ![naming](/docs/images/naming.png) 36 | 37 | The design of the plugin factory can bring the following benefits: 38 | - For the framework side: the framework only defines standard interfaces, without any plugin implementation, and is completely decoupled from the specific platform; 39 | - For the platform side: You only need to implement the plugin according to the standard interface of the framework plugin, and integrate the capabilities of the platform into the framework; 40 | - For the user side: developers only need to be used through configuration, which is transparent to users; 41 | 42 | ## Filter 43 | 44 | In order to make the tRPC framework more scalable and meet personalized developers needs (such as metrics, log collection, tracing, parameter verification, request replay, fault injection, etc.), tRPC use java's aspect-oriented programming(AOP) idea to support filter. 45 | 46 | The overall idea of filter implementation is to set up buried points in the framework's process of processing RPC requests, and then insert a series of filters into the buried points. 47 | 48 | The filter workflow is as follows: 49 | 50 | ![fitler](/docs/images/filter.png) 51 | 52 | The ultimate goal of filter is to decouple business logic from the framework and allow them to develop cohesively. It can dynamically add or replace personalized functions to business programs without modifying the framework code. 53 | 54 | # Pluggable Archtecture 55 | 56 | With the above key technical supporting, let’s take a look at how the tRPC pluggable architecture is designed. 57 | 58 | ## Overall Architectural Design 59 | 60 | The overall architecture design of tRPC is as follows: 61 | 62 | ![architecture_design](/docs/images/architecture.png) 63 | 64 | The overall architecture consists of two parts: "**Framework Core**" and "**Plugin**". The dotted line box is tRPC, the red solid line box in the middle is the core of the framework, and the blue box is the plugin part. 65 | 66 | The core of the framework can be divided into three layers: 67 | 68 | - **Communication Layer**: responsible for data transmission and protocol encoding and decoding. the framework has built-in support for communication protocols such as tcp and udp and uses the tRPC protocol based on Protobuf to carry RPC messages. It also supports other transmission protocols through codec plugins; 69 | 70 | - **Service Governance Layer**: responsible for abstracting service governance functions into plugins and connecting them with service governance systems by calling plugins to realize service discovery, load balance, monitor, tracing, etc. 71 | 72 | - **Call Layer**: encapsulates services and service proxy entities, provides RPC call interfaces, and supports synchronous, asynchronous, one-way and streaming calls; 73 | 74 | In addition, the framework also provides an admin management interface, so that users or the operation platform can manage services by calling the admin interface. The management interface includes functions such as updating configurations, viewing versions, modifying log levels, viewing framework runtime information, etc. At the same time, the framework also supports user-defined management interfaces to meet business customization needs. 75 | 76 | Plugins are the bridge that connects the framework core and external service governance systems. They are roughly divided into the following plugin types according to their functions: 77 | - Codec: provides interfaces related to protocol encoding and decoding, allowing expansion of customized protocols, serialization methods, data compression methods through plugins; 78 | - Naming: provides service registration (registry), service discovery (selector), load balance, circuit breaker and other capability encapsulation, used to connect with various naming service systems; 79 | - Config: provides interfaces to read local configuration files, remote configuration center configurations, etc., allows plugin extensions to support configuration files in different formats, different configuration centers, and supports reload and watch configuration updates; 80 | - Metrics: provides interfaces to report monitor data, supports common single-dimensional reporting, such as counter, gauge, etc., and also supports multi-dimensional reporting; 81 | - Logging: Provides a general log collection interface, allowing the log implementation to be extended through plugins and output to remote locations; 82 | - Tracing: Provides distributed tracing capabilities, allowing reporting to the call chain system through plugins; 83 | - Telemetry: provides the ability to collect and report telemetry data. It is a plugin that integrates tracing, metrics and logging; 84 | 85 | When implementing a specific plugin, one needs to implement the plugin according to the standard interface of the plugin, register it in the core of the framework, and complete plugin instantiation; on the other side, the specific plugin also needs to implement features (such as service discovery, load balance) based on using the SDK or API of the external service governance system. 86 | 87 | ## Specific Architecture Design 88 | 89 | Before talking about the specific architecture design, let's first look at the process of RPC. From a developer's perspective, it allows you to make cross-node function call like local function call. Usually a complete RPC process is as follows: 90 | 91 | ![rpc](/docs/images/rpc.png) 92 | 93 | The above figure describes the steps that an RPC call must go through. Based on this commonality, we divide the framework into server and client horizontally and layer it vertically. Among them, the vertical server is roughly divided into Transport, Codec, Service and Filter layers, and the client is divided into Transport, Codec, ServiceProxy and Filter layers. The specific design is as follows: 94 | 95 | ![rpc](/docs/images/layer.png) 96 | 97 | In this picture, we have added a new layer of filter layer. Its main purpose is to use the idea of ​​AOP to meet customized needs (such as parameter verification, log replay, fault injection, etc.) and service governance (such as metrics, tracing, logging, authentication, etc.) that are inserted into the request/response processing process in a cross-cutting manner. This design enhances the framework's scalability. 98 | 99 | At the same time, tRPC modularizes each layer and adopts pluggable implementation. The framework connects the entire process of RPC calls through the idea of interface-based programming. For some modules, the framework also adopts a more fine-grained module splitting. For example: the Selector module is subdivided into sub-modules such as service discovery, service routing, load balanc and etc., and the Codec layer is also subdivided into three sub-modules: encode/decode, serialization and compression. 100 | 101 | Through the above overall layered design, pluggable implementation of specific modules and fine-grained module splitting, the framework has strong scalability and openness. Businesses can flexibly replace plugins to achieve connecting with different systems, and can also implement personalized capabilities. 102 | -------------------------------------------------------------------------------- /docs/en/plugin_ecosystem.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | This article introduces the plugin ecosystem of tRPC. 4 | 5 | # Maturity classification 6 | 7 | In terms of maturity, tRPC plugins are currently divided into the following 4 levels: 8 | 9 | | Maturity | Description | 10 | | -------- | -------------------------------- | 11 | | stable | Already used on a large scale | 12 | | on trial | It has been tested and has been used in certain businesses | 13 | | tested | It has been tested and has not been used in business yet. | 14 | | archived | Archived, no longer maintained, and not recommended for use | 15 | 16 | # Plugin ecosystem in each language 17 | 18 | The plugin types of tRPC mainly include codec, filter, naming, config, metrics, tracing, logging, telemetry, etc. 19 | 20 | ## tRPC-Cpp plugin ecosystem 21 | 22 | | Type | Plugin | Maturity | Doc | 23 | | -------- | -------- | :------: | :---------------------------------------------------------------------------------: | 24 | | Codec | HTTP | stable | [link](https://github.com/trpc-group/trpc-cpp/blob/main/docs/en/http_protocol_service.md) | 25 | | Codec | gRPC | stable | [link](https://github.com/trpc-group/trpc-cpp/blob/main/docs/en/grpc_protocol_service.md) | 26 | | Serialiazation | Protobuf | stable | [link](https://github.com/trpc-group/trpc-cpp/blob/main/docs/en/serialization.md) | 27 | | Serialiazation | JSON | stable | [link](https://github.com/trpc-group/trpc-cpp/blob/main/docs/en/serialization.md) | 28 | | Serialiazation | text | stable | [link](https://github.com/trpc-group/trpc-cpp/blob/main/docs/en/serialization.md) | 29 | | Serialiazation | binary | stable | [link](https://github.com/trpc-group/trpc-cpp/blob/main/docs/en/serialization.md) | 30 | | Compressor | Gzip | stable | [link](https://github.com/trpc-group/trpc-cpp/blob/main/docs/en/compression.md) | 31 | | Compressor | lz4 | stable | [link](https://github.com/trpc-group/trpc-cpp/blob/main/docs/en/compression.md) | 32 | | Compressor | Snappy | stable | [link](https://github.com/trpc-group/trpc-cpp/blob/main/docs/en/compression.md) | 33 | | Compressor | zlib | stable | [link](https://github.com/trpc-group/trpc-cpp/blob/main/docs/en/compression.md) | 34 | | naming | MeshPolaris | tested | [link](https://github.com/trpc-group/cpp-naming-polarismesh/blob/main/README.md) | 35 | | config | etcd | tested | [link](https://github.com/trpc-group/cpp-config-etcd/blob/main/README.md) | 36 | | metrics | Prometheus | stable | [link](https://github.com/trpc-group/trpc-cpp/blob/main/docs/en/prometheus_metrics.md) | 37 | | tracing | Jaeger | stable | [link](https://github.com/trpc-group/cpp-tracing-jaeger/blob/main/README_zh.md) | 38 | | logging | CLS | stable | [link](https://github.com/trpc-group/cpp-logging-cls/blob/main/README_zh.md) | 39 | | telemetry | OpenTelemetry | stable | [link](https://github.com/trpc-group/cpp-telemetry-opentelemetry/blob/main/README_zh.md) | 40 | 41 | ## tRPC-Go plugin ecosystem 42 | 43 | | Type | Plugin | Maturity | Doc | 44 | | -------- | -------- | :------: | :---------------------------------------------------------------------------------: | 45 | | Codec | HTTP | stable | [link](https://github.com/trpc-group/trpc-go/tree/main/http) | 46 | | Codec | gRPC | stable | [link](https://github.com/trpc-ecosystem/go-codec/tree/main/grpc) | 47 | | naming | MeshPolaris | tested | [link](https://github.com/trpc-ecosystem/go-naming-polarismesh) | 48 | | config | etcd | tested | [link](https://github.com/trpc-ecosystem/go-config-etcd) | 49 | | metrics | Prometheus | stable | [link](https://github.com/trpc-ecosystem/go-metrics-prometheus) | 50 | | tracing | Jaeger | stable | [link](https://github.com/trpc-ecosystem/go-opentracing-jaeger) | 51 | | logging | CLS | stable | [link](https://github.com/trpc-ecosystem/go-log-cls) | 52 | | telemetry | OpenTelemetry | stable | [link](https://github.com/trpc-ecosystem/go-opentelementry) | 53 | | filter | debuglog | stable | [link](https://github.com/trpc-ecosystem/go-filter/tree/main/debuglog) | 54 | | filter | degrade | stable | [link](https://github.com/trpc-ecosystem/go-filter/tree/main/degrade) | 55 | | filter | filterextensions | stable | [link](https://github.com/trpc-ecosystem/go-filter/tree/main/filterextensions) | 56 | | filter | hystrix | stable | [link](https://github.com/trpc-ecosystem/go-filter/tree/main/hystrix) | 57 | | filter | jwt | stable | [link](https://github.com/trpc-ecosystem/go-filter/tree/main/jwt) | 58 | | filter | masking | stable | [link](https://github.com/trpc-ecosystem/go-filter/tree/main/masking) | 59 | | filter | mock(client mock)| stable | [link](https://github.com/trpc-ecosystem/go-filter/tree/main/mock) | 60 | | filter | recover )| stable | [link](https://github.com/trpc-ecosystem/go-filter/tree/main/recovery) | 61 | | filter | referer | stable | [link](https://github.com/trpc-ecosystem/go-filter/tree/main/referer) | 62 | | filter | slime | stable | [link](https://github.com/trpc-ecosystem/go-filter/tree/main/slime) | 63 | | filter | transinfo-blocker | stable | [link](https://github.com/trpc-ecosystem/go-filter/tree/main/transinfo-blocker) | 64 | | filter | tvar | stable | [link](https://github.com/trpc-ecosystem/go-filter/tree/main/tvar) | 65 | | filter | validation | stable | [link](https://github.com/trpc-ecosystem/go-filter/tree/main/validation) | 66 | -------------------------------------------------------------------------------- /docs/en/terminology.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | This article mainly introduces some terms in tRPC service development, including service naming, service route naming, interface naming, etc., so that everyone can have a unified understanding of these naming rules and avoid misunderstandings. 4 | 5 | # Naming Specification 6 | 7 | Usually, business online service will include multiple business subsystems, and each business subsystem includes multiple independent services. Calls between these services generally use special route names to indirectly get the callee's IP/port for accessing, rather than directly use the hard-coding IP/port. Therefore, the service will first register its route name to the naming service system, and then use it as the unique identity of the service. This requires that the name of the service must be unique among many micro-services. At the same time, under the micro-service architecture, with so many services, how can a certain service be quickly identified through some information of the service, so as to facilitate the operation and maintenance management of the service, such as service deployment, monitoring, alarming, etc. This also has certain standard requirements for the naming of services. 8 | 9 | Therefore, in order to facilitate the management of service development, service route, service operation and maintenance, etc., tRPC has made some standardized designs for service naming, route naming, and RPC interface naming (of course, these standardized names are only recommendations and are not mandatory). 10 | 11 | ## Service Naming 12 | 13 | tRPC defines the following three dimensions of service naming: 14 | 1. app name, which represents the name of a certain business system and is used to identify a collection of different service modules; 15 | 2. server name (module name), which represents the name of the specific service module, generally also called the process name; 16 | 3. service name, which represents the name of the specific service provider. Generally, the service name defined in the proto file; 17 | 18 | The benefits of service naming like this are: 19 | 1. For service development, scaffolding tools can be used to automatically generate tRPC service code; 20 | 2. For service addressing, a globally unique service route name can be generated to facilitate service registration and service discovery; 21 | 3. For service operation, it can facilitate service deployment, monitor data collection, alarms, etc.; 22 | 23 | The following figure is a flow chart of service A using RPC to call service B: 24 | 25 | ![rpc_workflow](/docs/images/rpc_workflow.png) 26 | 27 | Among them, service A serves as the client and service B serves as the server. In tRPC, we call the client also the caller and the server the callee. After the caller A obtains the ip/port list from the naming service through the name of the service route (Route ID), it then sets the callee RPC interface name (Interface ID) in the communication protocol and accesses the callee B. 28 | 29 | Next, let's take a look at the rules for service route naming and RPC interface naming, as well as the direct relationship between Service and service route name. 30 | 31 | ## service route naming 32 | 33 | In order to facilitate addressing of the service, the service route naming convention is as follows: 34 | 35 | It is composed of four segments of string **"trpc.{app}.{server}.{service}"** separated by `.`. 36 | 37 | Among them, the first paragraph is fixed to `trpc`, indicating that this service is a tRPC service. The second to fourth paragraphs refer to the meaning of service naming. 38 | 39 | The combination of `trpc.{app}.{server}` must be globally unique. In addition, the name of caller and callee are generally consistent with the service route name. 40 | 41 | ## RPC Interface Naming 42 | 43 | Next, let's take a look at how the callee calls the corresponding RPC method to process the request based on the message information of the caller in tRPC? This involves the caller and the callee have unified specifications for the naming of RPC methods in the message communication protocol. 44 | 45 | The following is a simple interface proto file provided by the service 46 | 47 | ```protobuf 48 | syntax = "proto3"; 49 | 50 | package trpc.test.helloworld; 51 | 52 | service Greeter { 53 | rpc SayHello (HelloRequest) returns (HelloReply) {} 54 | } 55 | 56 | message HelloRequest { 57 | string msg = 1; 58 | } 59 | 60 | message HelloReply { 61 | string msg = 1; 62 | } 63 | 64 | ``` 65 | 66 | Based on the usage of the Protobuf, tRPC has formulated a unified specification for the name of the RPC interface on the trpc protocol. The RPC method name is composed of **"/{package_name}.{service_name}/{method_name}"** in the proto file. 67 | 68 | Among them, we recommend using `trpc.{app}.{server}` for the name of `{package_name}`, `{service_name}` is the service name defined in the proto file above, and `{method_name}` is the specific method name under the service , that is the RPC interface we want to call. 69 | 70 | 71 | ## Mapping of service and service route name 72 | 73 | First of all, Service here refers to the Service defined in the proto file, which is responsible for defining a series of RPC interfaces. The Service instance is the specific object of the Service, and the service route name is the name for service addressing. When providing services, we need to associate the three and find the service provider through the service route name. 74 | 75 | tRPC recommends that a server program only provide one proto service and Service instance, which corresponds to a servie route name, and use one protocol and one port to provide interface service. The service assembly model is shown in the figure: 76 | 77 | ![single_proto_single_service_instance](/docs/images/single_proto_single_service_instance.png) 78 | 79 | tRPC also supports a server program to provide only one proto service and instantiate multiple service instances. Each Service instance corresponds to a service route name and uses one protocol and one port to provide interface service. The ports of different service instances cannot be the same. The service assembly model is shown in the figure: 80 | 81 | ![single_proto_multi_service_instance](/docs/images/single_proto_multi_service_instance.png) 82 | 83 | tRPC also supports a server program to provide multiple proto services. Different proto services can instantiate one or more service instances. Each service instance corresponds to service route name and uses one protocol and one port to provide interface service. The ports of different service instances cannot be the same. The service assembly model is shown in the figure: 84 | 85 | ![multi_proto_multi_service_instance](/docs/images/multi_proto_multi_service_instance.png) 86 | 87 | Note: tRPC does not support multiple protocols on the same port. 88 | 89 | -------------------------------------------------------------------------------- /docs/images/architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trpc-group/trpc/398abb395da5ac2a7da1806e9253f488737a18e2/docs/images/architecture.png -------------------------------------------------------------------------------- /docs/images/codec.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trpc-group/trpc/398abb395da5ac2a7da1806e9253f488737a18e2/docs/images/codec.png -------------------------------------------------------------------------------- /docs/images/filter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trpc-group/trpc/398abb395da5ac2a7da1806e9253f488737a18e2/docs/images/filter.png -------------------------------------------------------------------------------- /docs/images/layer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trpc-group/trpc/398abb395da5ac2a7da1806e9253f488737a18e2/docs/images/layer.png -------------------------------------------------------------------------------- /docs/images/multi_proto_multi_service_instance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trpc-group/trpc/398abb395da5ac2a7da1806e9253f488737a18e2/docs/images/multi_proto_multi_service_instance.png -------------------------------------------------------------------------------- /docs/images/naming.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trpc-group/trpc/398abb395da5ac2a7da1806e9253f488737a18e2/docs/images/naming.png -------------------------------------------------------------------------------- /docs/images/rpc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trpc-group/trpc/398abb395da5ac2a7da1806e9253f488737a18e2/docs/images/rpc.png -------------------------------------------------------------------------------- /docs/images/rpc_workflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trpc-group/trpc/398abb395da5ac2a7da1806e9253f488737a18e2/docs/images/rpc_workflow.png -------------------------------------------------------------------------------- /docs/images/single_proto_multi_service_instance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trpc-group/trpc/398abb395da5ac2a7da1806e9253f488737a18e2/docs/images/single_proto_multi_service_instance.png -------------------------------------------------------------------------------- /docs/images/single_proto_single_service_instance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trpc-group/trpc/398abb395da5ac2a7da1806e9253f488737a18e2/docs/images/single_proto_single_service_instance.png -------------------------------------------------------------------------------- /docs/images/trpc-protocol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trpc-group/trpc/398abb395da5ac2a7da1806e9253f488737a18e2/docs/images/trpc-protocol.png -------------------------------------------------------------------------------- /docs/images/wireshark/pic1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trpc-group/trpc/398abb395da5ac2a7da1806e9253f488737a18e2/docs/images/wireshark/pic1.png -------------------------------------------------------------------------------- /docs/images/wireshark/pic10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trpc-group/trpc/398abb395da5ac2a7da1806e9253f488737a18e2/docs/images/wireshark/pic10.png -------------------------------------------------------------------------------- /docs/images/wireshark/pic2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trpc-group/trpc/398abb395da5ac2a7da1806e9253f488737a18e2/docs/images/wireshark/pic2.png -------------------------------------------------------------------------------- /docs/images/wireshark/pic3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trpc-group/trpc/398abb395da5ac2a7da1806e9253f488737a18e2/docs/images/wireshark/pic3.png -------------------------------------------------------------------------------- /docs/images/wireshark/pic4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trpc-group/trpc/398abb395da5ac2a7da1806e9253f488737a18e2/docs/images/wireshark/pic4.png -------------------------------------------------------------------------------- /docs/images/wireshark/pic5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trpc-group/trpc/398abb395da5ac2a7da1806e9253f488737a18e2/docs/images/wireshark/pic5.png -------------------------------------------------------------------------------- /docs/images/wireshark/pic6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trpc-group/trpc/398abb395da5ac2a7da1806e9253f488737a18e2/docs/images/wireshark/pic6.png -------------------------------------------------------------------------------- /docs/images/wireshark/pic7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trpc-group/trpc/398abb395da5ac2a7da1806e9253f488737a18e2/docs/images/wireshark/pic7.png -------------------------------------------------------------------------------- /docs/images/wireshark/pic8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trpc-group/trpc/398abb395da5ac2a7da1806e9253f488737a18e2/docs/images/wireshark/pic8.png -------------------------------------------------------------------------------- /docs/images/wireshark/pic9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trpc-group/trpc/398abb395da5ac2a7da1806e9253f488737a18e2/docs/images/wireshark/pic9.png -------------------------------------------------------------------------------- /docs/zh/architecture_design.md: -------------------------------------------------------------------------------- 1 | # 前言 2 | 3 | 本文主要介绍一下tRPC诞生的背景、插件化设计思路、以及整体架构。 4 | 5 | # 背景 6 | 7 | 互联网发展早期,业务场景差异大,试错迭代速度很快。这导致其后台服务使用的语言技术栈、开发框架、通信协议、服务治理系统、运维平台等或多或少存在差异。 8 | 9 | 业务发展到一定阶段后,跨业务合作越来越多,组织架构调整也愈发频繁。技术体系差异,特别是开发框架的不统一,给业务互通带来巨大成本,也导致开发和运营的效率难以快速提高。 10 | 11 | 同时,随着云原生技术的发展,业务越来越多地使用开源技术和云组件。拥抱云原生已经是一种主流趋势。 12 | 13 | 上述问题在腾讯内部也同样存在,且因为规模大、业务类型多,更加难以解决,更必须解决。tRPC就是在这种背景下诞生的。 14 | 15 | # 插件化设计 16 | 17 | 既要与存量技术体系互联互通,又要适配云原生技术并且快速发展。这就要求开发框架必须具备开放性和可扩展性。为了达到这个目的,tRPC在架构设计上采用插件化设计思想。 18 | 19 | tRPC插件化在整体设计上遵循如下的思想: 20 | 21 | 首先tRPC对框架整体进行分层和模块化,并把核心功能模块抽象封装成一个个独立的插件。然后由框架来负责这些独立插件的串联和拼装,从而实现框架所要支持的功能和特性。 22 | 23 | 在具体实现上,则采用以下的关键技术 24 | 1. 基于接口机制的插件工厂; 25 | 2. 基于AOP思想的拦截器; 26 | 27 | ## 插件工厂 28 | 29 | 插件工厂的整体实现思路是框架只定义插件的标准接口,并提供注册能力,不做具体实现。与外部服务互通,或者对接某个服务治理系统时,只需要开发对应的具体插件即可。 30 | 31 | 例如: 框架对多协议的支持,定义了统一的Codec,不同协议只需要按照Codec接口即可实现即可。 32 | 33 | ![codec](/docs/images/codec.png) 34 | 35 | 例如: 框架对接不同名字服务系统,定义了统一的Registry和Selector抽象接口,对接不同的名字服务系统时只需要按照Registry和Selector接口即可实现即可。 36 | 37 | ![naming](/docs/images/naming.png) 38 | 39 | 通过插件工厂的设计,可以带来以下的好处: 40 | - 对于框架侧: 框架只定义标准接口,没有任何插件实现,与具体平台完全解耦; 41 | 42 | - 对于平台侧: 只需要按照框架插件标准接口即可实现插件,即可将平台的能力融入到框架中; 43 | 44 | - 对于用户侧: 业务开发只需要通过配置进行使用,对用户透明; 45 | 46 | ## 拦截器 47 | 48 | 为了使tRPC框架有更强的可扩展性,满足业务个性化的需求(比如:metrics监控、日志收集、链路跟踪、参数校验、请求回放、故障注入等),tRPC借鉴了Java面向切面(AOP)的编程思想,支持了拦截器filter。 49 | 50 | filter整体实现的思路是在框架处理RPC请求的流程上设置埋点,然后通过在埋点地方插入一系列的filter。具体实现上,不同语言有所不同,Cpp采用数组遍历的方式,Go采用递归的方式,Java采用链式的方式。 51 | 52 | filter工作流程如下图: 53 | 54 | ![fitler](/docs/images/filter.png) 55 | 56 | filter的最终目的是让业务逻辑与框架进行解耦,并允许各自进行内聚性开发,可以在不修改框架代码的情况下,给业务程序动态添加或替换个性化的功能。 57 | 58 | # 插件化架构 59 | 60 | 有了上面插件化的关键技术支持,接下来我们看看tRPC插件化架构是怎样设计的。 61 | 62 | ## 总体架构设计 63 | 64 | tRPC多语言的总体架构设计如下: 65 | 66 | ![architecture_design](/docs/images/architecture.png) 67 | 68 | 总体架构由 "**框架核心**" 和 "**插件**" 两部分组成。 其中虚线框内为tRPC,中间的红色实线框为框架核心,蓝色框为插件部分。 69 | 70 | 框架核心又可以分三层: 71 | 72 | - **通信层**: 负责数据的传输和协议的编解码,框架内置支持TCP、UDP等通信协议,传输协议采用基于Protobuf的tRPC协议来承载RPC调用,支持通过codec插件来使用其它传输协议; 73 | 74 | - **服务治理层**: 负责将服务治理功能抽象成插件,通过调用插件和外部服务治理系统进行对接,实现服务发现、负载均衡、监控、调用链等功能; 75 | 76 | - **调用层**: 封装服务和服务代理实体,提供RPC调用接口,支持业务用同步、异步、单向以及流式调用等方式进行服务间调用; 77 | 78 | 此外框架还提供了admin管理接口,方便用户或者运营平台可以通过调用admin接口对服务进行管理。 管理接口包括更新配置、查看版本、修改日志级别、查看框架运行时信息等功能,同时框架也支持用户自定义管理接口,以满足业务定制化需求。 79 | 80 | 插件则是框架核心和外部服务治理组件串联起来的桥梁,按功能大致分为下面几类插件: 81 | - codec: 提供协议编解码相关的接口,允许通过插件的方式来扩展业务协议、序列化方式、数据压缩方式等协议处理; 82 | - naming:提供了服务注册(registry)、服务发现(selector)、负载均衡(loadbalance)、熔断(circuitbreaker)等能力封装,用于对接各种名字服务系统; 83 | - config:提供了配置读取相关的接口,支持读取本地配置文件、远程配置中心配置等,允许插件式扩展支持不同格式的配置文件、不同的配置中心,支持reload、watch配置更新; 84 | - metrics:提供了监控上报的能力,支持常见的单维上报,如 counter、gauge 等,也支持多维上报,允许通过扩展对接不同的监控系统; 85 | - logging:提供了通用的日志采集接口,允许通过插件的方式来扩展日志实现,输出到远程; 86 | - tracing:提供了分布式跟踪能力,允许通过插件的方式上报到调用链系统; 87 | - telemetry:提供了采集和上报遥测数据的能力,是一个集成了链路追踪(tracing)、监控上报(metrics)、日志采集(logging)三大功能的插件; 88 | 89 | 具体插件实现时,一边需要按框架标准接口实现插件,注册到框架核心,并完成插件实例化;另一边具体插件还需要使用外部服务治理服务的SDK或API,实现如服务发现、负载均衡、监控、调用链等功能。 90 | 91 | ## 具体架构设计 92 | 93 | 在讲具体架构设计之前,我们先看看RPC调用的过程是怎样的。从开发者角度来说,它可以让你像本地函数调用一样进行跨节点的函数调用,通常一个完整的RPC过程如下图: 94 | 95 | ![rpc](/docs/images/rpc.png) 96 | 97 | 上图描述了一个RPC调用必须要经过的环节。基于此共性,我们把框架在横向上分为服务端和客户端,在纵向进行分层。其中,纵向上的服务端大致分为Transport、Codec、Service和Filter层,客户端分为Transport、Codec、ServiceProxy、Filter层,具体设计如下图: 98 | 99 | ![rpc](/docs/images/layer.png) 100 | 101 | 在这张图中,我们新增了一层filter层(拦截器),其主要目的是采用AOP的思想,把业务个性化的需求(比如:校验校验、请求回放、故障注入等)、以及服务治理的大部分功能(比如:监控指标上报,调用链跟踪,远程日志,鉴权等)以横切关注点的方式,插入到请求/响应处理的流程中,通过这样的设计来增强框架的可扩展性。 102 | 103 | 同时系统对每一层进行模块化拆分,采用插件化的实现,框架通过基于接口编程的思想,串联RPC调用的全流程。对于一些模块,框架也采用了更细粒度的模块拆分。比如:Selector模块被细分为服务发现、服务路由、负载均衡和熔断等子模块,Codec层也被细分为编解码、序列化、压缩三个子模块。 104 | 105 | 通过上面整体的分层设计,具体模块的插件化实现和细粒度的模块拆分,使框架具备很强的扩展性和开放性。业务可以灵活替换插件,实现与不同系统的对接,也可以进行业务个性化定制能力实现。 106 | -------------------------------------------------------------------------------- /docs/zh/plugin_ecosystem.md: -------------------------------------------------------------------------------- 1 | # 前言 2 | 3 | 本文主要介绍一下tRPC目前的插件生态建设情况。 4 | 5 | # tRPC插件的成熟度分类 6 | 7 | tRPC插件在成熟度上,目前分为以下4级: 8 | 9 | | 成熟度 | 描述 | 10 | | -------- | -------------------------------- | 11 | | stable | 已经大规模使用,放心使用 | 12 | | on trial | 已测试,有一定业务用过,基本靠谱 | 13 | | tested | 已测试,还没有业务用过,可能有坑 | 14 | | archived | 已归档,不再维护,不推荐使用 | 15 | 16 | # tRPC各语言的插件生态建设情况 17 | 18 | 目前tRPC在插件生态的建设上,插件类型主要包含协议、拦截器、名字服务系统、配置中心系统、监控系统、调用链系统、远程日志系统、可观测系统等。 19 | 20 | ## tRPC-Cpp插件列表 21 | 22 | | 插件类型 | 插件 | 成熟度 | 文档 | 23 | | -------- | -------- | :------: | :---------------------------------------------------------------------------------: | 24 | | 协议 | HTTP | stable | [链接](https://github.com/trpc-group/trpc-cpp/blob/main/docs/zh/http_protocol_service.md) | 25 | | 协议 | gRPC | stable | [链接](https://github.com/trpc-group/trpc-cpp/blob/main/docs/zh/grpc_protocol_service.md) | 26 | | 序列化 | Protobuf | stable | [链接](https://github.com/trpc-group/trpc-cpp/blob/main/docs/zh/serialization.md) | 27 | | 序列化 | JSON | stable | [链接](https://github.com/trpc-group/trpc-cpp/blob/main/docs/zh/serialization.md) | 28 | | 序列化 | text | stable | [链接](https://github.com/trpc-group/trpc-cpp/blob/main/docs/zh/serialization.md) | 29 | | 序列化 | binary | stable | [链接](https://github.com/trpc-group/trpc-cpp/blob/main/docs/zh/serialization.md) | 30 | | 解压缩 | Gzip | stable | [链接](https://github.com/trpc-group/trpc-cpp/blob/main/docs/zh/compression.md) | 31 | | 解压缩 | lz4 | stable | [链接](https://github.com/trpc-group/trpc-cpp/blob/main/docs/zh/compression.md) | 32 | | 解压缩 | Snappy | stable | [链接](https://github.com/trpc-group/trpc-cpp/blob/main/docs/zh/compression.md) | 33 | | 解压缩 | zlib | stable | [链接](https://github.com/trpc-group/trpc-cpp/blob/main/docs/zh/compression.md) | 34 | | 名字服务系统 | MeshPolaris | tested | [链接](https://github.com/trpc-group/cpp-naming-polarismesh/blob/main/README_zh.md) | 35 | | 配置中心系统 | etcd | tested | [链接](https://github.com/trpc-group/cpp-config-etcd/blob/main/README_zh.md) | 36 | | 监控系统 | Prometheus | stable | [链接](https://github.com/trpc-group/trpc-cpp/blob/main/docs/zh/prometheus_metrics.md) | 37 | | 调用链系统 | Jaeger | stable | [链接](https://github.com/trpc-group/cpp-tracing-jaeger/blob/main/README_zh.md) | 38 | | 远程日志系统 | CLS | stable | [链接](https://github.com/trpc-group/cpp-logging-cls/blob/main/README_zh.md) | 39 | | 可观测系统 | OpenTelemetry | stable | [链接](https://github.com/trpc-group/cpp-telemetry-opentelemetry/blob/main/README_zh.md) | 40 | 41 | ## tRPC-Go插件列表 42 | 43 | | 插件类型 | 插件 | 成熟度 | 文档 | 44 | | -------- | -------- | :------: | :---------------------------------------------------------------------------------: | 45 | | 协议 | HTTP | stable | [链接](https://github.com/trpc-group/trpc-go/tree/main/http) | 46 | | 协议 | gRPC | stable | [链接](https://github.com/trpc-ecosystem/go-codec/tree/main/grpc) | 47 | | 名字服务系统 | MeshPolaris | tested | [链接](https://github.com/trpc-ecosystem/go-naming-polarismesh) | 48 | | 配置中心系统 | etcd | tested | [链接](https://github.com/trpc-ecosystem/go-config-etcd) | 49 | | 监控系统 | Prometheus | stable | [链接](https://github.com/trpc-ecosystem/go-metrics-prometheus) | 50 | | 调用链系统 | Jaeger | stable | [链接](https://github.com/trpc-ecosystem/go-opentracing-jaeger) | 51 | | 远程日志系统 | CLS | stable | [链接](https://github.com/trpc-ecosystem/go-log-cls) | 52 | | 可观测系统 | OpenTelemetry | stable | [链接](https://github.com/trpc-ecosystem/go-opentelementry) | 53 | | 拦截器 | debuglog | stable | [链接](https://github.com/trpc-ecosystem/go-filter/tree/main/debuglog) | 54 | | 拦截器 | degrade(服务端熔断限流)| stable | [链接](https://github.com/trpc-ecosystem/go-filter/tree/main/degrade) | 55 | | 拦截器 | filterextensions(方法级别的拦截器)| stable | [链接](https://github.com/trpc-ecosystem/go-filter/tree/main/filterextensions) | 56 | | 拦截器 | hystrix(服务端熔断限流)| stable | [链接](https://github.com/trpc-ecosystem/go-filter/tree/main/hystrix) | 57 | | 拦截器 | jwt (认证鉴权)| stable | [链接](https://github.com/trpc-ecosystem/go-filter/tree/main/jwt) | 58 | | 拦截器 | masking(敏感数据脱敏)| stable | [链接](https://github.com/trpc-ecosystem/go-filter/tree/main/masking) | 59 | | 拦截器 | mock(client mock)| stable | [链接](https://github.com/trpc-ecosystem/go-filter/tree/main/mock) | 60 | | 拦截器 | recover(捕获 panic 并恢复)| stable | [链接](https://github.com/trpc-ecosystem/go-filter/tree/main/recovery) | 61 | | 拦截器 | referer(HTTP Referer 安全校验)| stable | [链接](https://github.com/trpc-ecosystem/go-filter/tree/main/referer) | 62 | | 拦截器 | slime(重试/对冲)| stable | [链接](https://github.com/trpc-ecosystem/go-filter/tree/main/slime) | 63 | | 拦截器 | transinfo-blocker(元数据透传屏障)| stable | [链接](https://github.com/trpc-ecosystem/go-filter/tree/main/transinfo-blocker) | 64 | | 拦截器 | tvar(统计监控)| stable | [链接](https://github.com/trpc-ecosystem/go-filter/tree/main/tvar) | 65 | | 拦截器 | validation(参数自动校验)| stable | [链接](https://github.com/trpc-ecosystem/go-filter/tree/main/validation) | 66 | -------------------------------------------------------------------------------- /docs/zh/terminology.md: -------------------------------------------------------------------------------- 1 | # 前言 2 | 3 | 本文主要介绍一下tRPC服务开发中的一些名词术语,包括服务命名、服务路由命名、接口命名等,方便大家对这些命名规则有统一的认识,避免产生误解。 4 | 5 | # tRPC命名规范 6 | 7 | 通常线上提供的业务服务,会包括多个业务子系统,每个业务子系统内部又包括多个独立服务。这些服务之间的调用一般都是使用专门的路由名字间接寻址到被调用者的ip/port来进行访问的,而不是直接写死ip/port。因此,服务会先把自身的路由名字会注册到名字服务系统中,然后将其作为这个服务的唯一身份,方便主调服务进行识别,这就要求服务自身的命名能在众多微服务中具有唯一性。同时在微服务架构下,服务很多,如何通过服务的一些信息能快速识别某个服务,方便对服务日常的运维管理,比如:服务部署、监控、告警等,这也对服务的命名有一定的规范要求。 8 | 9 | 因此,为了能方便对服务开发、服务路由、服务运维等进行管理,tRPC对服务命名、路由命名、RPC接口命名做了一些规范设计(当然这些规范名称只是推荐,不做强制要求)。 10 | 11 | ## 服务命名 12 | 13 | tRPC在服务命名上定义了以下3个纬度信息: 14 | 1. app名(应用名),表示某个业务系统的名称,用于标识某个业务下不同服务模块的一个集合; 15 | 2. server名(模块名),表示具体服务模块的名称,一般也称为模块的进程名称; 16 | 3. service名,表示具体服务提供者的名称,一般使用proto文件定义的Service名称; 17 | 其中`app.server` 的组合在全局上要具备唯一性。 18 | 19 | 服务命名这样定义的好处是: 20 | 1. 对于服务开发,可以方便脚手架工具自动生成tRPC服务代码; 21 | 2. 对于服务寻址,可以生成全局唯一的服务路由名称,方便服务注册和服务发现; 22 | 3. 对于服务运营,可以方便服务的部署、各种维度的监控数据采集、告警等; 23 | 24 | 下图是服务A使用RPC调用服务B的流程图: 25 | 26 | ![rpc_workflow](/docs/images/rpc_workflow.png) 27 | 28 | 其中服务A作为客户端,服务B作为服务端,在tRPC中我们称客户端也为 `主调(caller)`,服务端也为 `被调(callee)`。主调(caller)A通过服务路由的名字(Route ID)向名字服务拿到ip/port列表后,然后在通信协议中设置调用的RPC接口名(Interface ID),访问被调B(callee)。 29 | 30 | 接下来,我们来看看服务路由命名和RPC接口命名的规则,以及具体服务时Service与服务路由名字直接的关系是怎样的。 31 | 32 | ## 服务路由命名 33 | 34 | 为了方便对服务的路由寻址,服务的路由命名规范如下: 35 | 36 | 由`.`号分割的四段字符串 **"trpc.{app}.{server}.{service}"** 来组成。 37 | 38 | 其中,第1段固定为`trpc`,表示这个服务是一个tRPC服务,第2段到第4段参考服务命名的含义。 39 | 40 | 另外,主调(caller)与被调(callee)的命名一般也与服务的路由命名一致。 41 | 42 | ## RPC接口命名 43 | 44 | 接下来我们看看tRPC中被调如何根据主调的消息信息调用相应RPC方法来处理请求的?这就涉及到主调方与被调方在消息通信协议上对RPC方法的命名有统一的规范. 45 | 46 | 下面是一个比较简单的服务提供的接口proto文件 47 | 48 | ```protobuf 49 | syntax = "proto3"; 50 | 51 | package trpc.test.helloworld; 52 | 53 | service Greeter { 54 | rpc SayHello (HelloRequest) returns (HelloReply) {} 55 | } 56 | 57 | message HelloRequest { 58 | string msg = 1; 59 | } 60 | 61 | message HelloReply { 62 | string msg = 1; 63 | } 64 | 65 | ``` 66 | 67 | 基于proto文件的用法,tRPC在tRPC协议上对RPC接口的名字制定了统一的规范,RPC调用方法名由proto文件中的 **"/{package_name}.{service_name}/{method_name}"** 组成。其中 `{package_name}` 的命名我们建议使用 `trpc.{app}.{server}`,`{service_name}` 为上面proto文件中定义的service名字,`{method_name}` 为service下具体的方法名,即我们要调用的RPC接口。 68 | 69 | ## Service与路由名字的映射 70 | 71 | 首先,这里Service指的是proto文件中定义的Service,它负责定义一系列RPC接口,Service实例是Service具体的对象,而路由名字则是进行服务寻址的名字。对外提供服务时,我们需要把三者关联起来,通过路由名字来找到具体proto的Service提供者。 72 | 73 | tRPC建议一个服务端程序只提供一个proto Service,实例化一个Service实例,其对应一个路由名字,使用一种协议和一个port对外提供接口服务。 服务组装模式如图所示: 74 | 75 | ![single_proto_single_service_instance](/docs/images/single_proto_single_service_instance.png) 76 | 77 | tRPC也支持一个服务端程序只提供一个proto Service,实例化多个Service实例,每个Service实例其对应一个路由名字,使用一种协议和一个port对外提供接口服务,不同Service实例的port不能一样。 服务组装模式如图所示: 78 | 79 | ![single_proto_multi_service_instance](/docs/images/single_proto_multi_service_instance.png) 80 | 81 | tRPC也支持一个服务端程序只提供多个proto Service,不同proto Service可以实例化1个或者多个Service实例,每个Service实例其对应一个路由名字,使用一种协议和一个port对外提供接口服务,不同Service实例的port不能一样。 服务组装模式如图所示: 82 | 83 | ![multi_proto_multi_service_instance](/docs/images/multi_proto_multi_service_instance.png) 84 | 85 | 注意:tRPC不支持同一个端口支持多协议。 86 | -------------------------------------------------------------------------------- /docs/zh/trpc_protocol_design.md: -------------------------------------------------------------------------------- 1 | # 前言 2 | 3 | 本文主要介绍一下为什么要设计tRPC协议,以及tRPC协议具体是怎样定义。 4 | 5 | # 为什么要设计tRPC协议 6 | 7 | 首先,tRPC是一个多语言的RPC框架,需要有统一的传输协议进行通信,以及通信时在一些功能上进行对齐。 8 | 9 | 其次,为什么tRPC不选择HTTP/HTTP2协议,这里主要的原因是性能问题。 10 | 11 | 最后,除了向前兼容外,tRPC在通信协议上还有强烈扩展性的诉求,能扩展支持各种业务需求的能力。 12 | 13 | 下面的表格是tRPC对通信协议的能力和诉求。 14 | 15 | | 能力 | 诉求 | 16 | | ------------ | ------------ | 17 | | RPC | 远程调用像调本地接口一样 | 18 | | 兼容性 | 协议设计和实现上应具有向前兼容 | 19 | | 高性能 | 协议设计上需要考虑高性能问题 | 20 | | 流式传输 | 协议设计上应该能支持大数据包传输和边请求边应答的流式场景 | 21 | | 支持请求超时控制 | 协议设计和实现上支持设置请求超时时间 | 22 | | 支持多种序列化方式 | 协议设计和实现上可扩展支持多种序列化方式,比如:Protobuf、JSON、text等 | 23 | | 支持多种解压缩方式 | 协议设计和实现上可扩展支持多种解压缩方式,比如:Gzip、Snappy等 | 24 | | 支持透传调用链信息 | 协议设计和实现上支持调用链信息在服务间透传 | 25 | | 支持消息染色 | 协议设计和实现上支持请求消息的染色key在服务间透传 | 26 | | 支持透传用户自定义元数据 | 协议设计和实现上支持用户设置自定义元数据在服务间透传 | 27 | 28 | 为了支持这些能力和需求,tRPC协议整体设计设计如下: 29 | 30 | 传输协议(协议头,自定义设计)+ 编码协议(协议体,默认使用Protobuf,可扩展) 31 | 32 | # tRPC协议具体设计与实现 33 | 34 | ## 协议设计 35 | 36 | 下面的图是tRPC协议的具体设计。 37 | 38 | ![ 'image.png'](/docs/images/trpc-protocol.png) 39 | 40 | tRPC协议支持一应一答和流式两种传输方式。 41 | 42 | 对于一应一答(unary)的RPC,整个完整协议帧 = 固定帧头(16字节)+ Unary包头(变长)+ Unary包体(变长) 43 | 44 | 对于流式(stream)RPC,整个完整协议帧 = 固定帧头(16字节)+ 流帧(Init帧、Data帧、Feedback帧、Close帧) 45 | 46 | 完整的协议定义,可以查看:[trpc.proto](https://github.com/trpc-group/trpc/blob/main/trpc/trpc.proto) 47 | 48 | ## 协议具体定义 49 | 50 | ### 固定帧头 51 | - 第1-2个字节: 52 | 协议前面两个字节为魔数字,标识tRPC帧的开始,为0x930 53 | 54 | - 第3个字节:数据类型 55 | 56 | ```protobuf 57 | // Two types are currently supported: 58 | // 1. The data frame type for unary(one-response-one-response) 59 | // 2. The data frame type for streaming 60 | enum TrpcDataFrameType { 61 | TRPC_UNARY_FRAME = 0x00; 62 | 63 | TRPC_STREAM_FRAME = 0x01; 64 | } 65 | ``` 66 | 67 | - 第4个字节: 68 | 流式帧类型,只有帧为流式的帧的时候生效 69 | 70 | ```protobuf 71 | // Four types are currently supported: 72 | // `INIT` frame: FIXHEADER + TrpcStreamInitMeta 73 | // `DATA` frame: FIXHEADER + body (business serialized data) 74 | // `FEEDBACK` frame: FIXHEADER + TrpcStreamFeedBackMeta (triggered strategy: high/low water level and timer) 75 | // `CLOSE` frame: FIXHEADER + TrpcStreamCloseMeta 76 | enum TrpcStreamFrameType { 77 | TRPC_UNARY = 0x00; 78 | 79 | TRPC_STREAM_FRAME_INIT = 0x01; 80 | 81 | TRPC_STREAM_FRAME_DATA = 0x02; 82 | 83 | TRPC_STREAM_FRAME_FEEDBACK = 0x03; 84 | 85 | TRPC_STREAM_FRAME_CLOSE = 0x04; 86 | } 87 | ``` 88 | 89 | - 第5-8个字节 90 | 数据总大小 91 | 对于一应一答,总数据大小 = 帧头大小 + 包头大小 + 包体大小 92 | 对于流式,总数据大小 = 帧头大小 + 流帧大小 93 | 94 | - 第9-10个字节: 95 | 对于一应一答,包头大小 96 | 对于流式,始终为0 97 | 98 | - 第11-14个字节: 99 | 对于一应一答,请求id 100 | 对流式,流式id 101 | 102 | - 第15-16个字节 103 | 保留字段,保留给以后扩容协议使用 104 | 105 | ### 一应一答包头 106 | 107 | 16个字节之后,对于一应一答,对应着协议的包头,分为请求包头和响应包头 108 | 109 | #### 请求包头 110 | 111 | ```protobuf 112 | // The request header for unary 113 | message RequestProtocol { 114 | // The version of protocol 115 | // The specific value corresponds to `TrpcProtoVersion` 116 | uint32 version = 1; 117 | 118 | // Call type 119 | // eg: unary, one-way 120 | // The specific value corresponds to `TrpcCallType` 121 | uint32 call_type = 2; 122 | 123 | // The unique id of the request(on the conneciton) 124 | uint32 request_id = 3; 125 | 126 | // The timeout of the request(ms) 127 | uint32 timeout = 4; 128 | 129 | // Caller name 130 | // The specification format: trpc.application_name.server_name.proto_service_name, 4 segments 131 | bytes caller = 5; 132 | 133 | // Callee name 134 | // The specification format: trpc.application_name.server_name.proto_service_name[.interface_name] 135 | bytes callee = 6; 136 | 137 | // Interface name of callee 138 | // The specification format: /package.service_name/interface_name 139 | bytes func = 7; 140 | 141 | // The message type of the transparent transmission information 142 | // such as tracing, dyeing key, gray, authentication, multi-environment, set name, etc. 143 | // The specific value corresponds to `TrpcMessageType` 144 | uint32 message_type = 8; 145 | 146 | // The information key-value pair transparently transmitted by the framework 147 | // Currently divided into two parts: 148 | // 1 part is the information to be transparently transmitted by the framework layer, 149 | // and the name of the key must be started with `trpc-`` 150 | // 2 part is the information to be transparently transmitted by the business layer, 151 | // and the business can set it by itself, it is recommended to start with `app-``, not `trpc-` 152 | // Note: The key-value pair in trans_info will be transparently transmitted through the whole link, please use it carefully for business. 153 | map trans_info = 9; 154 | 155 | // The serialization type of the request data 156 | // eg: proto/json/.., default proto 157 | // The specific value corresponds to `TrpcContentEncodeType` 158 | uint32 content_type = 10; 159 | 160 | // The compression type of the requested data 161 | // eg: gzip/snappy/..., not used by default 162 | // The specific value corresponds to `TrpcCompressType` 163 | uint32 content_encoding = 11; 164 | 165 | // The size of attachment data 166 | uint32 attachment_size = 12; 167 | } 168 | ``` 169 | 170 | #### 响应包头 171 | 172 | ```protobuf 173 | // The response header for unary 174 | message ResponseProtocol { 175 | // The version of protocol 176 | // The specific value corresponds to `TrpcProtoVersion` 177 | uint32 version = 1; 178 | 179 | // Call type 180 | // eg: unary, one-way 181 | // The specific value corresponds to `TrpcCallType` 182 | uint32 call_type = 2; 183 | 184 | // The unique id of the request(on the conneciton) 185 | uint32 request_id = 3; 186 | 187 | // Error code 188 | // The specific value corresponds to `TrpcRetCode` 189 | int32 ret = 4; 190 | 191 | // The error code of the interface 192 | // 0 means success, other means failure 193 | int32 func_ret = 5; 194 | 195 | // The result information when the call fails 196 | bytes error_msg = 6; 197 | 198 | // The message type of the transparent transmission information 199 | // such as tracing, dyeing key, gray, authentication, multi-environment, set name, etc. 200 | // The specific value corresponds to `TrpcMessageType` 201 | uint32 message_type = 7; 202 | 203 | // The information key-value pair transparently transmitted by the framework 204 | // Currently divided into two parts: 205 | // 1 part is the information to be transparently transmitted by the framework layer, 206 | // and the name of the key must be started with `trpc-`` 207 | // 2 part is the information to be transparently transmitted by the business layer, 208 | // and the business can set it by itself, it is recommended to start with `app-``, not `trpc-` 209 | map trans_info = 8; 210 | 211 | // The serialization type of the request data 212 | // eg: proto/json/.., default proto 213 | // The specific value corresponds to `TrpcContentEncodeType` 214 | uint32 content_type = 9; 215 | 216 | // The compression type of the requested data 217 | // eg: gzip/snappy/..., not used by default 218 | // The specific value corresponds to `TrpcCompressType` 219 | uint32 content_encoding = 10; 220 | 221 | // The size of attachment data 222 | uint32 attachment_size = 12; 223 | } 224 | ``` 225 | 226 | ### 流式流帧 227 | 228 | 16个字节完整帧头后面紧接着流帧 229 | 230 | 分为 Init、Data、Feedback、Close 帧 231 | - Init帧用来做流初始化 232 | 233 | - Data帧用来传输流式数据 234 | 235 | - Feedback帧用来传输流控消息 236 | 237 | - Close帧用来关闭流 238 | 239 | #### Init帧 240 | 241 | ```protobuf 242 | // The message definition of streaming `INIT` frame 243 | message TrpcStreamInitMeta { 244 | // request meta information 245 | TrpcStreamInitRequestMeta request_meta = 1; 246 | 247 | // response meta information 248 | TrpcStreamInitResponseMeta response_meta = 2; 249 | 250 | // The window size is notified by the receiver to the sender 251 | uint32 init_window_size = 3; 252 | 253 | // The serialization type of the request data 254 | // eg: proto/json/.., default proto 255 | // The specific value corresponds to `TrpcContentEncodeType` 256 | uint32 content_type = 4; 257 | 258 | // The compression type of the requested data 259 | // eg: gzip/snappy/..., not used by default 260 | // The specific value corresponds to `TrpcCompressType` 261 | uint32 content_encoding = 5; 262 | } 263 | ``` 264 | 265 | ```protobuf 266 | // The request meta information definition of streaming `INIT` frame 267 | message TrpcStreamInitRequestMeta { 268 | // Caller name 269 | // The specification format: trpc.application_name.server_name.proto_service_name, 4 segments 270 | bytes caller = 1; 271 | 272 | // Callee name 273 | // The specification format: trpc.application_name.server_name.proto_service_name[.interface_name] 274 | bytes callee = 2; 275 | 276 | // Interface name of callee 277 | // The specification format: /package.service_name/interface_name 278 | bytes func = 3; 279 | 280 | // The message type of the transparent transmission information 281 | // such as tracing, dyeing key, gray, authentication, multi-environment, set name, etc. 282 | // The specific value corresponds to `TrpcMessageType` 283 | uint32 message_type = 4; 284 | 285 | // The information key-value pair transparently transmitted by the framework 286 | // Currently divided into two parts: 287 | // 1 part is the information to be transparently transmitted by the framework layer, 288 | // and the name of the key must be started with `trpc-`` 289 | // 2 part is the information to be transparently transmitted by the business layer, 290 | // and the business can set it by itself, it is recommended to start with `app-``, not `trpc-` 291 | // Note: The key-value pair in trans_info will be transparently transmitted through the whole link, please use it carefully for business. 292 | map trans_info = 5; 293 | }; 294 | ``` 295 | 296 | ```protobuf 297 | // The response meta information definition of streaming `INIT` frame 298 | message TrpcStreamInitResponseMeta { 299 | // Error code 300 | // The specific value corresponds to `TrpcRetCode` 301 | int32 ret = 1; 302 | 303 | // The result information when the call fails 304 | bytes error_msg = 2; 305 | }; 306 | ``` 307 | 308 | #### Data帧 309 | 310 | DATA帧对应的是实际请求的消息体 311 | 312 | #### Feedback帧 313 | 314 | ```protobuf 315 | // The meta information definition of streaming `FEEDBACK` frame 316 | message TrpcStreamFeedBackMeta { 317 | // increased window size 318 | uint32 window_size_increment = 1; 319 | } 320 | ``` 321 | 322 | #### Close帧 323 | 324 | Close帧分为正常的 Close帧 和 异常的 Close(Reset)帧。 325 | 326 | ```protobuf 327 | // The closed type of trpc streaming protocol 328 | enum TrpcStreamCloseType { 329 | // normal closes unidirectional flow 330 | TRPC_STREAM_CLOSE = 0; 331 | 332 | // Exception closes bidirectional stream 333 | TRPC_STREAM_RESET = 1; 334 | } 335 | ``` 336 | 337 | ```protobuf 338 | // The meta information definition of trpc streaming protocol for closing stream 339 | message TrpcStreamCloseMeta { 340 | // The type of stream closure, close one end, or close all 341 | int32 close_type = 1; 342 | 343 | // Error code 344 | // The specific value corresponds to `TrpcRetCode` 345 | int32 ret = 2; 346 | 347 | // The result information when the call fails 348 | bytes msg = 3; 349 | 350 | // The message type of the transparent transmission information 351 | // such as tracing, dyeing key, gray, authentication, multi-environment, set name, etc. 352 | // The specific value corresponds to `TrpcMessageType` 353 | uint32 message_type = 4; 354 | 355 | // The information key-value pair transparently transmitted by the framework 356 | // Currently divided into two parts: 357 | // 1 part is the information to be transparently transmitted by the framework layer, 358 | // and the name of the key must be started with `trpc-`` 359 | // 2 part is the information to be transparently transmitted by the business layer, 360 | // and the business can set it by itself, it is recommended to start with `app-``, not `trpc-` 361 | // Note: The key-value pair in trans_info will be transparently transmitted through the whole link, please use it carefully for business. 362 | map trans_info = 5; 363 | 364 | // The error code of the interface 365 | // 0 means success, other means failure 366 | int32 func_ret = 6; 367 | } 368 | ``` 369 | 370 | ## IDL 371 | 372 | tRPC 的IDL基于Protobuf,用户编写Proto文件,通过trpc-cmdline生成相应的桩代码 373 | 374 | ### 一应一答RPC的IDL 375 | 376 | ```protobuf 377 | syntax = "proto3"; 378 | 379 | package proto; 380 | 381 | service StreamService { 382 | rpc List(Request) returns ( Response) {}; 383 | rpc Record( Request) returns (Response) {}; 384 | rpc Route( StreamRequest) returns ( Response) {}; 385 | } 386 | 387 | 388 | message Point { 389 | string name = 1; 390 | int32 value = 2; 391 | } 392 | 393 | message Request { 394 | Point pt = 1; 395 | } 396 | 397 | message Response { 398 | Point pt = 1; 399 | } 400 | ``` 401 | 402 | ### 流式RPC的IDL 403 | 404 | 流式IDL和普通RPC一样,使用stream关键字表明是流式RPC 405 | 406 | ```protobuf 407 | syntax = "proto3"; 408 | 409 | package proto; 410 | 411 | service StreamService { 412 | rpc List(StreamRequest) returns (stream StreamResponse) {}; 413 | rpc Record(stream StreamRequest) returns (StreamResponse) {}; 414 | rpc Route(stream StreamRequest) returns (stream StreamResponse) {}; 415 | } 416 | 417 | 418 | message StreamPoint { 419 | string name = 1; 420 | int32 value = 2; 421 | } 422 | 423 | message StreamRequest { 424 | StreamPoint pt = 1; 425 | } 426 | 427 | message StreamResponse { 428 | StreamPoint pt = 1; 429 | } 430 | ``` 431 | 注意关键字 stream,声明其为一个流方法。这里共涉及三个方法,对应关系为 432 | - List:服务器端流式RPC 433 | - Record:客户端流式RPC 434 | - Route:双向流式RPC 435 | -------------------------------------------------------------------------------- /docs/zh/wireshark_trpc.md: -------------------------------------------------------------------------------- 1 | # tRPC Wireshark解析器 2 | 3 | ## 前言 4 | 5 | `tool/wireshark_trpc.lua` 是 tRPC 协议的 Wireshark 解析器,提供了对 tRPC 协议头、业务 pb 的解析能力。 6 | 7 | 当前使用有如下限制: 8 | 9 | 1. 暂不支持解析tRPC流式协议; 10 | 2. 暂不支持attachment; 11 | 3. 暂不支持UDP; 12 | 4. 不支持解析开启压缩后的pb数据(业务pb数据会被压缩); 13 | 14 | ## 用法 15 | 16 | ### tcpdump抓包 17 | 18 | 执行下面的tcpdump抓包 19 | 20 | ```bash 21 | # 10001 替换为服务端端口 22 | tcpdump -iany port 10001 -w trpc_packet.pcap 23 | ``` 24 | 25 | **注意:** 有时可能因为机器环境问题,导致tcpdump抓包被截断,比如只抓了请求包的部分,wireshark使用lua脚本解析会失败,这时可以抓包时使用 `-s xxx` 防止截断,代表调整低于xxx字节的packet不截断。 26 | 27 | ### Wireshark配置 28 | 29 | 1. 从选项卡 `About Wireshark` -> `Floders` 查看 `Personal Lua Plugins` 的目录。 30 | 31 | 32 | 33 | 2. 进入 `Personal Lua Plugins` 目录,放入 [wireshark_trpc.lua](../../tool/wireshark_trpc.lua)。 34 | 35 | 36 | 37 | 3. 设置proto扫描文件目录,并开启基于protobuf的解析。 38 | 39 | - 此文件目录下需要放置 [trpc.proto](../../trpc/trpc.proto)以及业务pb,比如此处我们使用 tRPC-Cpp 示例的 [helloworld.proto](https://github.com/trpc-group/trpc-cpp/blob/main/examples/helloworld/helloworld.proto)。 40 | - 需要勾选 `Load .proto files on startup.`、`Dissect Protobuf fields as Wireshark fields.`、`Show details of message, fields and enums.`、`Show all fields of bytes type as string.` 以通过protobuf解析器来解析字段。 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | ### Wireshark加载tcpdump抓包 49 | 50 | 加载包之后,如果没有看到 `Protocol` 显示 `tRPC`,需要强制加载下lua脚本。 51 | 52 | 53 | 54 | 如果都成功,能看如下图所示tRPC协议以及业务pb都被正常解析了。 55 | 56 | 57 | 58 | 59 | 60 | ### 筛选指定请求和响应 61 | 62 | 有时会发现并发很多个请求,可能有某几个请求会调用失败,为了进一步排查,需要更多tRPC协议/业务pb字段等信息,这时候可以通过 protobuf 字段来筛选出指定请求/响应。 63 | 64 | Wireshark 支持通过 protobuf 字段做筛选,业务可以选择使用trpc协议头的 request_id 或者业务 pb 某个字段做匹配来查看指定请求和响应的交互情况。 65 | 66 | 下面是根据trpc协议头的 `requet_id=3` 筛选指定请求和响应的示例,大家可根据自身情况指定筛选条件。 67 | 68 | ```text 69 | protobuf.field.name == "request_id" and protobuf.field.value == 3 70 | ``` 71 | 72 | 73 | 74 | ### 忽略tcp的控制帧 75 | 76 | 我们更多的会关注协议包的交互情况,而不关注tcp控制帧(tcp握手/挥手等),这时可以通过设置下面的筛选条件清除tcp控制帧的显示。 77 | 78 | ```text 79 | protobuf 80 | ``` 81 | 82 | 83 | -------------------------------------------------------------------------------- /pb/go/trpc/api/annotations.pb.go: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making tRPC available. 2 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved. 3 | // If you have downloaded a copy of the tRPC source code from Tencent, 4 | // please note that tRPC source code is licensed under the Apache 2.0 License, 5 | // A copy of the Apache 2.0 License is included in this file. 6 | 7 | // Copyright 2015 Google LLC 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | // 21 | // This file may have been modified by THL A29 Limited ("Tencent Modifications"). 22 | // All Tencent Modifications are Copyright (C) 2023 THL A29 Limited. 23 | 24 | // Code generated by protoc-gen-go. DO NOT EDIT. 25 | // versions: 26 | // protoc-gen-go v1.28.1 27 | // protoc v5.27.1 28 | // source: trpc/api/annotations.proto 29 | 30 | package api 31 | 32 | import ( 33 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 34 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 35 | descriptorpb "google.golang.org/protobuf/types/descriptorpb" 36 | reflect "reflect" 37 | ) 38 | 39 | const ( 40 | // Verify that this generated code is sufficiently up-to-date. 41 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 42 | // Verify that runtime/protoimpl is sufficiently up-to-date. 43 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 44 | ) 45 | 46 | var file_trpc_api_annotations_proto_extTypes = []protoimpl.ExtensionInfo{ 47 | { 48 | ExtendedType: (*descriptorpb.MethodOptions)(nil), 49 | ExtensionType: (*HttpRule)(nil), 50 | Field: 50201, 51 | Name: "trpc.api.http", 52 | Tag: "bytes,50201,opt,name=http", 53 | Filename: "trpc/api/annotations.proto", 54 | }, 55 | { 56 | ExtendedType: (*descriptorpb.MessageOptions)(nil), 57 | ExtensionType: (*Schema)(nil), 58 | Field: 50201, 59 | Name: "trpc.api.openapiv2_schema", 60 | Tag: "bytes,50201,opt,name=openapiv2_schema", 61 | Filename: "trpc/api/annotations.proto", 62 | }, 63 | } 64 | 65 | // Extension fields to descriptorpb.MethodOptions. 66 | var ( 67 | // optional trpc.api.HttpRule http = 50201; 68 | E_Http = &file_trpc_api_annotations_proto_extTypes[0] 69 | ) 70 | 71 | // Extension fields to descriptorpb.MessageOptions. 72 | var ( 73 | // optional trpc.api.Schema openapiv2_schema = 50201; 74 | E_Openapiv2Schema = &file_trpc_api_annotations_proto_extTypes[1] 75 | ) 76 | 77 | var File_trpc_api_annotations_proto protoreflect.FileDescriptor 78 | 79 | var file_trpc_api_annotations_proto_rawDesc = []byte{ 80 | 0x0a, 0x1a, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 81 | 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x74, 0x72, 82 | 0x70, 0x63, 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x13, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x61, 0x70, 0x69, 83 | 0x2f, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, 0x74, 0x72, 0x70, 84 | 0x63, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 85 | 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 86 | 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 87 | 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3a, 0x48, 0x0a, 0x04, 0x68, 0x74, 0x74, 0x70, 0x12, 88 | 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 89 | 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 90 | 0x99, 0x88, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x61, 91 | 0x70, 0x69, 0x2e, 0x48, 0x74, 0x74, 0x70, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x04, 0x68, 0x74, 0x74, 92 | 0x70, 0x3a, 0x5e, 0x0a, 0x10, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x5f, 0x73, 93 | 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 94 | 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4f, 95 | 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x99, 0x88, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 96 | 0x2e, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 97 | 0x52, 0x0f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x53, 0x63, 0x68, 0x65, 0x6d, 98 | 0x61, 0x42, 0x4d, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, 0x63, 0x65, 0x6e, 0x74, 99 | 0x2e, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x65, 100 | 0x78, 0x74, 0x5a, 0x2c, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2f, 0x74, 101 | 0x72, 0x70, 0x63, 0x2f, 0x74, 0x72, 0x70, 0x63, 0x2d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 102 | 0x6c, 0x2f, 0x70, 0x62, 0x2f, 0x67, 0x6f, 0x2f, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x61, 0x70, 0x69, 103 | 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 104 | } 105 | 106 | var file_trpc_api_annotations_proto_goTypes = []interface{}{ 107 | (*descriptorpb.MethodOptions)(nil), // 0: google.protobuf.MethodOptions 108 | (*descriptorpb.MessageOptions)(nil), // 1: google.protobuf.MessageOptions 109 | (*HttpRule)(nil), // 2: trpc.api.HttpRule 110 | (*Schema)(nil), // 3: trpc.api.Schema 111 | } 112 | var file_trpc_api_annotations_proto_depIdxs = []int32{ 113 | 0, // 0: trpc.api.http:extendee -> google.protobuf.MethodOptions 114 | 1, // 1: trpc.api.openapiv2_schema:extendee -> google.protobuf.MessageOptions 115 | 2, // 2: trpc.api.http:type_name -> trpc.api.HttpRule 116 | 3, // 3: trpc.api.openapiv2_schema:type_name -> trpc.api.Schema 117 | 4, // [4:4] is the sub-list for method output_type 118 | 4, // [4:4] is the sub-list for method input_type 119 | 2, // [2:4] is the sub-list for extension type_name 120 | 0, // [0:2] is the sub-list for extension extendee 121 | 0, // [0:0] is the sub-list for field type_name 122 | } 123 | 124 | func init() { file_trpc_api_annotations_proto_init() } 125 | func file_trpc_api_annotations_proto_init() { 126 | if File_trpc_api_annotations_proto != nil { 127 | return 128 | } 129 | file_trpc_api_http_proto_init() 130 | file_trpc_api_openapiv2_proto_init() 131 | type x struct{} 132 | out := protoimpl.TypeBuilder{ 133 | File: protoimpl.DescBuilder{ 134 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 135 | RawDescriptor: file_trpc_api_annotations_proto_rawDesc, 136 | NumEnums: 0, 137 | NumMessages: 0, 138 | NumExtensions: 2, 139 | NumServices: 0, 140 | }, 141 | GoTypes: file_trpc_api_annotations_proto_goTypes, 142 | DependencyIndexes: file_trpc_api_annotations_proto_depIdxs, 143 | ExtensionInfos: file_trpc_api_annotations_proto_extTypes, 144 | }.Build() 145 | File_trpc_api_annotations_proto = out.File 146 | file_trpc_api_annotations_proto_rawDesc = nil 147 | file_trpc_api_annotations_proto_goTypes = nil 148 | file_trpc_api_annotations_proto_depIdxs = nil 149 | } 150 | -------------------------------------------------------------------------------- /pb/go/trpc/api/http.pb.go: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making tRPC available. 2 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved. 3 | // If you have downloaded a copy of the tRPC source code from Tencent, 4 | // please note that tRPC source code is licensed under the Apache 2.0 License, 5 | // A copy of the Apache 2.0 License is included in this file. 6 | 7 | // Copyright 2023 Google LLC 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | // 21 | // This file may have been modified by THL A29 Limited ("Tencent Modifications"). 22 | // All Tencent Modifications are Copyright (C) 2023 THL A29 Limited. 23 | 24 | // Code generated by protoc-gen-go. DO NOT EDIT. 25 | // versions: 26 | // protoc-gen-go v1.28.1 27 | // protoc v5.27.1 28 | // source: trpc/api/http.proto 29 | 30 | package api 31 | 32 | import ( 33 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 34 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 35 | reflect "reflect" 36 | sync "sync" 37 | ) 38 | 39 | const ( 40 | // Verify that this generated code is sufficiently up-to-date. 41 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 42 | // Verify that runtime/protoimpl is sufficiently up-to-date. 43 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 44 | ) 45 | 46 | type HttpRule struct { 47 | state protoimpl.MessageState 48 | sizeCache protoimpl.SizeCache 49 | unknownFields protoimpl.UnknownFields 50 | 51 | // Selects a method to which this rule applies. 52 | // 53 | // Refer to [selector][google.api.DocumentationRule.selector] for syntax details. 54 | Selector string `protobuf:"bytes,1,opt,name=selector,proto3" json:"selector,omitempty"` 55 | // Determines the URL pattern is matched by this rules. This pattern can be 56 | // used with any of the {get|put|post|delete|patch} methods. A custom method 57 | // can be defined using the 'custom' field. 58 | // 59 | // Types that are assignable to Pattern: 60 | // *HttpRule_Get 61 | // *HttpRule_Put 62 | // *HttpRule_Post 63 | // *HttpRule_Delete 64 | // *HttpRule_Patch 65 | // *HttpRule_Custom 66 | Pattern isHttpRule_Pattern `protobuf_oneof:"pattern"` 67 | // The name of the request field whose value is mapped to the HTTP request 68 | // body, or `*` for mapping all request fields not captured by the path 69 | // pattern to the HTTP body, or omitted for not having any HTTP request body. 70 | // 71 | // NOTE: the referred field must be present at the top-level of the request 72 | // message type. 73 | Body string `protobuf:"bytes,7,opt,name=body,proto3" json:"body,omitempty"` 74 | // Optional. The name of the response field whose value is mapped to the HTTP 75 | // response body. When omitted, the entire response message will be used 76 | // as the HTTP response body. 77 | // 78 | // NOTE: The referred field must be present at the top-level of the response 79 | // message type. 80 | ResponseBody string `protobuf:"bytes,12,opt,name=response_body,json=responseBody,proto3" json:"response_body,omitempty"` 81 | // Additional HTTP bindings for the selector. Nested bindings must 82 | // not contain an `additional_bindings` field themselves (that is, 83 | // the nesting may only be one level deep). 84 | AdditionalBindings []*HttpRule `protobuf:"bytes,11,rep,name=additional_bindings,json=additionalBindings,proto3" json:"additional_bindings,omitempty"` 85 | } 86 | 87 | func (x *HttpRule) Reset() { 88 | *x = HttpRule{} 89 | if protoimpl.UnsafeEnabled { 90 | mi := &file_trpc_api_http_proto_msgTypes[0] 91 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 92 | ms.StoreMessageInfo(mi) 93 | } 94 | } 95 | 96 | func (x *HttpRule) String() string { 97 | return protoimpl.X.MessageStringOf(x) 98 | } 99 | 100 | func (*HttpRule) ProtoMessage() {} 101 | 102 | func (x *HttpRule) ProtoReflect() protoreflect.Message { 103 | mi := &file_trpc_api_http_proto_msgTypes[0] 104 | if protoimpl.UnsafeEnabled && x != nil { 105 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 106 | if ms.LoadMessageInfo() == nil { 107 | ms.StoreMessageInfo(mi) 108 | } 109 | return ms 110 | } 111 | return mi.MessageOf(x) 112 | } 113 | 114 | // Deprecated: Use HttpRule.ProtoReflect.Descriptor instead. 115 | func (*HttpRule) Descriptor() ([]byte, []int) { 116 | return file_trpc_api_http_proto_rawDescGZIP(), []int{0} 117 | } 118 | 119 | func (x *HttpRule) GetSelector() string { 120 | if x != nil { 121 | return x.Selector 122 | } 123 | return "" 124 | } 125 | 126 | func (m *HttpRule) GetPattern() isHttpRule_Pattern { 127 | if m != nil { 128 | return m.Pattern 129 | } 130 | return nil 131 | } 132 | 133 | func (x *HttpRule) GetGet() string { 134 | if x, ok := x.GetPattern().(*HttpRule_Get); ok { 135 | return x.Get 136 | } 137 | return "" 138 | } 139 | 140 | func (x *HttpRule) GetPut() string { 141 | if x, ok := x.GetPattern().(*HttpRule_Put); ok { 142 | return x.Put 143 | } 144 | return "" 145 | } 146 | 147 | func (x *HttpRule) GetPost() string { 148 | if x, ok := x.GetPattern().(*HttpRule_Post); ok { 149 | return x.Post 150 | } 151 | return "" 152 | } 153 | 154 | func (x *HttpRule) GetDelete() string { 155 | if x, ok := x.GetPattern().(*HttpRule_Delete); ok { 156 | return x.Delete 157 | } 158 | return "" 159 | } 160 | 161 | func (x *HttpRule) GetPatch() string { 162 | if x, ok := x.GetPattern().(*HttpRule_Patch); ok { 163 | return x.Patch 164 | } 165 | return "" 166 | } 167 | 168 | func (x *HttpRule) GetCustom() *CustomHttpPattern { 169 | if x, ok := x.GetPattern().(*HttpRule_Custom); ok { 170 | return x.Custom 171 | } 172 | return nil 173 | } 174 | 175 | func (x *HttpRule) GetBody() string { 176 | if x != nil { 177 | return x.Body 178 | } 179 | return "" 180 | } 181 | 182 | func (x *HttpRule) GetResponseBody() string { 183 | if x != nil { 184 | return x.ResponseBody 185 | } 186 | return "" 187 | } 188 | 189 | func (x *HttpRule) GetAdditionalBindings() []*HttpRule { 190 | if x != nil { 191 | return x.AdditionalBindings 192 | } 193 | return nil 194 | } 195 | 196 | type isHttpRule_Pattern interface { 197 | isHttpRule_Pattern() 198 | } 199 | 200 | type HttpRule_Get struct { 201 | // Maps to HTTP GET. Used for listing and getting information about 202 | // resources. 203 | Get string `protobuf:"bytes,2,opt,name=get,proto3,oneof"` 204 | } 205 | 206 | type HttpRule_Put struct { 207 | // Maps to HTTP PUT. Used for replacing a resource. 208 | Put string `protobuf:"bytes,3,opt,name=put,proto3,oneof"` 209 | } 210 | 211 | type HttpRule_Post struct { 212 | // Maps to HTTP POST. Used for creating a resource or performing an action. 213 | Post string `protobuf:"bytes,4,opt,name=post,proto3,oneof"` 214 | } 215 | 216 | type HttpRule_Delete struct { 217 | // Maps to HTTP DELETE. Used for deleting a resource. 218 | Delete string `protobuf:"bytes,5,opt,name=delete,proto3,oneof"` 219 | } 220 | 221 | type HttpRule_Patch struct { 222 | // Maps to HTTP PATCH. Used for updating a resource. 223 | Patch string `protobuf:"bytes,6,opt,name=patch,proto3,oneof"` 224 | } 225 | 226 | type HttpRule_Custom struct { 227 | // The custom pattern is used for specifying an HTTP method that is not 228 | // included in the `pattern` field, such as HEAD, or "*" to leave the 229 | // HTTP method unspecified for this rule. The wild-card rule is useful 230 | // for services that provide content to Web (HTML) clients. 231 | Custom *CustomHttpPattern `protobuf:"bytes,8,opt,name=custom,proto3,oneof"` 232 | } 233 | 234 | func (*HttpRule_Get) isHttpRule_Pattern() {} 235 | 236 | func (*HttpRule_Put) isHttpRule_Pattern() {} 237 | 238 | func (*HttpRule_Post) isHttpRule_Pattern() {} 239 | 240 | func (*HttpRule_Delete) isHttpRule_Pattern() {} 241 | 242 | func (*HttpRule_Patch) isHttpRule_Pattern() {} 243 | 244 | func (*HttpRule_Custom) isHttpRule_Pattern() {} 245 | 246 | // A custom pattern is used for defining custom HTTP verb. 247 | type CustomHttpPattern struct { 248 | state protoimpl.MessageState 249 | sizeCache protoimpl.SizeCache 250 | unknownFields protoimpl.UnknownFields 251 | 252 | // The name of this custom HTTP verb. 253 | Kind string `protobuf:"bytes,1,opt,name=kind,proto3" json:"kind,omitempty"` 254 | // The path matched by this custom verb. 255 | Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` 256 | } 257 | 258 | func (x *CustomHttpPattern) Reset() { 259 | *x = CustomHttpPattern{} 260 | if protoimpl.UnsafeEnabled { 261 | mi := &file_trpc_api_http_proto_msgTypes[1] 262 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 263 | ms.StoreMessageInfo(mi) 264 | } 265 | } 266 | 267 | func (x *CustomHttpPattern) String() string { 268 | return protoimpl.X.MessageStringOf(x) 269 | } 270 | 271 | func (*CustomHttpPattern) ProtoMessage() {} 272 | 273 | func (x *CustomHttpPattern) ProtoReflect() protoreflect.Message { 274 | mi := &file_trpc_api_http_proto_msgTypes[1] 275 | if protoimpl.UnsafeEnabled && x != nil { 276 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 277 | if ms.LoadMessageInfo() == nil { 278 | ms.StoreMessageInfo(mi) 279 | } 280 | return ms 281 | } 282 | return mi.MessageOf(x) 283 | } 284 | 285 | // Deprecated: Use CustomHttpPattern.ProtoReflect.Descriptor instead. 286 | func (*CustomHttpPattern) Descriptor() ([]byte, []int) { 287 | return file_trpc_api_http_proto_rawDescGZIP(), []int{1} 288 | } 289 | 290 | func (x *CustomHttpPattern) GetKind() string { 291 | if x != nil { 292 | return x.Kind 293 | } 294 | return "" 295 | } 296 | 297 | func (x *CustomHttpPattern) GetPath() string { 298 | if x != nil { 299 | return x.Path 300 | } 301 | return "" 302 | } 303 | 304 | var File_trpc_api_http_proto protoreflect.FileDescriptor 305 | 306 | var file_trpc_api_http_proto_rawDesc = []byte{ 307 | 0x0a, 0x13, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x2e, 308 | 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x61, 0x70, 0x69, 0x22, 309 | 0xd6, 0x02, 0x0a, 0x08, 0x48, 0x74, 0x74, 0x70, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x1a, 0x0a, 0x08, 310 | 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 311 | 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x12, 0x0a, 0x03, 0x67, 0x65, 0x74, 0x18, 312 | 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x03, 0x67, 0x65, 0x74, 0x12, 0x12, 0x0a, 0x03, 313 | 0x70, 0x75, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x03, 0x70, 0x75, 0x74, 314 | 0x12, 0x14, 0x0a, 0x04, 0x70, 0x6f, 0x73, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 315 | 0x52, 0x04, 0x70, 0x6f, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x06, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 316 | 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x06, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 317 | 0x12, 0x16, 0x0a, 0x05, 0x70, 0x61, 0x74, 0x63, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x48, 318 | 0x00, 0x52, 0x05, 0x70, 0x61, 0x74, 0x63, 0x68, 0x12, 0x35, 0x0a, 0x06, 0x63, 0x75, 0x73, 0x74, 319 | 0x6f, 0x6d, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x74, 0x72, 0x70, 0x63, 0x2e, 320 | 0x61, 0x70, 0x69, 0x2e, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x48, 0x74, 0x74, 0x70, 0x50, 0x61, 321 | 0x74, 0x74, 0x65, 0x72, 0x6e, 0x48, 0x00, 0x52, 0x06, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x12, 322 | 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x62, 323 | 0x6f, 0x64, 0x79, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 324 | 0x62, 0x6f, 0x64, 0x79, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65, 0x73, 0x70, 325 | 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x43, 0x0a, 0x13, 0x61, 0x64, 0x64, 0x69, 326 | 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x18, 327 | 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x61, 0x70, 0x69, 328 | 0x2e, 0x48, 0x74, 0x74, 0x70, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x12, 0x61, 0x64, 0x64, 0x69, 0x74, 329 | 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x42, 0x09, 0x0a, 330 | 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x22, 0x3b, 0x0a, 0x11, 0x43, 0x75, 0x73, 0x74, 331 | 0x6f, 0x6d, 0x48, 0x74, 0x74, 0x70, 0x50, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x12, 0x12, 0x0a, 332 | 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 333 | 0x64, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 334 | 0x04, 0x70, 0x61, 0x74, 0x68, 0x42, 0x4d, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, 335 | 0x63, 0x65, 0x6e, 0x74, 0x2e, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 336 | 0x75, 0x66, 0x2e, 0x65, 0x78, 0x74, 0x5a, 0x2c, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x72, 0x6f, 337 | 0x75, 0x70, 0x2f, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x74, 0x72, 0x70, 0x63, 0x2d, 0x70, 0x72, 0x6f, 338 | 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x70, 0x62, 0x2f, 0x67, 0x6f, 0x2f, 0x74, 0x72, 0x70, 0x63, 339 | 0x2f, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 340 | } 341 | 342 | var ( 343 | file_trpc_api_http_proto_rawDescOnce sync.Once 344 | file_trpc_api_http_proto_rawDescData = file_trpc_api_http_proto_rawDesc 345 | ) 346 | 347 | func file_trpc_api_http_proto_rawDescGZIP() []byte { 348 | file_trpc_api_http_proto_rawDescOnce.Do(func() { 349 | file_trpc_api_http_proto_rawDescData = protoimpl.X.CompressGZIP(file_trpc_api_http_proto_rawDescData) 350 | }) 351 | return file_trpc_api_http_proto_rawDescData 352 | } 353 | 354 | var file_trpc_api_http_proto_msgTypes = make([]protoimpl.MessageInfo, 2) 355 | var file_trpc_api_http_proto_goTypes = []interface{}{ 356 | (*HttpRule)(nil), // 0: trpc.api.HttpRule 357 | (*CustomHttpPattern)(nil), // 1: trpc.api.CustomHttpPattern 358 | } 359 | var file_trpc_api_http_proto_depIdxs = []int32{ 360 | 1, // 0: trpc.api.HttpRule.custom:type_name -> trpc.api.CustomHttpPattern 361 | 0, // 1: trpc.api.HttpRule.additional_bindings:type_name -> trpc.api.HttpRule 362 | 2, // [2:2] is the sub-list for method output_type 363 | 2, // [2:2] is the sub-list for method input_type 364 | 2, // [2:2] is the sub-list for extension type_name 365 | 2, // [2:2] is the sub-list for extension extendee 366 | 0, // [0:2] is the sub-list for field type_name 367 | } 368 | 369 | func init() { file_trpc_api_http_proto_init() } 370 | func file_trpc_api_http_proto_init() { 371 | if File_trpc_api_http_proto != nil { 372 | return 373 | } 374 | if !protoimpl.UnsafeEnabled { 375 | file_trpc_api_http_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { 376 | switch v := v.(*HttpRule); i { 377 | case 0: 378 | return &v.state 379 | case 1: 380 | return &v.sizeCache 381 | case 2: 382 | return &v.unknownFields 383 | default: 384 | return nil 385 | } 386 | } 387 | file_trpc_api_http_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { 388 | switch v := v.(*CustomHttpPattern); i { 389 | case 0: 390 | return &v.state 391 | case 1: 392 | return &v.sizeCache 393 | case 2: 394 | return &v.unknownFields 395 | default: 396 | return nil 397 | } 398 | } 399 | } 400 | file_trpc_api_http_proto_msgTypes[0].OneofWrappers = []interface{}{ 401 | (*HttpRule_Get)(nil), 402 | (*HttpRule_Put)(nil), 403 | (*HttpRule_Post)(nil), 404 | (*HttpRule_Delete)(nil), 405 | (*HttpRule_Patch)(nil), 406 | (*HttpRule_Custom)(nil), 407 | } 408 | type x struct{} 409 | out := protoimpl.TypeBuilder{ 410 | File: protoimpl.DescBuilder{ 411 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 412 | RawDescriptor: file_trpc_api_http_proto_rawDesc, 413 | NumEnums: 0, 414 | NumMessages: 2, 415 | NumExtensions: 0, 416 | NumServices: 0, 417 | }, 418 | GoTypes: file_trpc_api_http_proto_goTypes, 419 | DependencyIndexes: file_trpc_api_http_proto_depIdxs, 420 | MessageInfos: file_trpc_api_http_proto_msgTypes, 421 | }.Build() 422 | File_trpc_api_http_proto = out.File 423 | file_trpc_api_http_proto_rawDesc = nil 424 | file_trpc_api_http_proto_goTypes = nil 425 | file_trpc_api_http_proto_depIdxs = nil 426 | } 427 | -------------------------------------------------------------------------------- /pb/go/trpc/api/openapiv2.pb.go: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making tRPC available. 2 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved. 3 | // If you have downloaded a copy of the tRPC source code from Tencent, 4 | // please note that tRPC source code is licensed under the Apache 2.0 License, 5 | // A copy of the Apache 2.0 License is included in this file. 6 | 7 | // Code generated by protoc-gen-go. DO NOT EDIT. 8 | // versions: 9 | // protoc-gen-go v1.28.1 10 | // protoc v5.27.1 11 | // source: trpc/api/openapiv2.proto 12 | 13 | package api 14 | 15 | import ( 16 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 17 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 18 | reflect "reflect" 19 | sync "sync" 20 | ) 21 | 22 | const ( 23 | // Verify that this generated code is sufficiently up-to-date. 24 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 25 | // Verify that runtime/protoimpl is sufficiently up-to-date. 26 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 27 | ) 28 | 29 | // message option schema 30 | type Schema struct { 31 | state protoimpl.MessageState 32 | sizeCache protoimpl.SizeCache 33 | unknownFields protoimpl.UnknownFields 34 | 35 | JsonSchema *JSONSchema `protobuf:"bytes,1,opt,name=json_schema,json=jsonSchema,proto3" json:"json_schema,omitempty"` 36 | } 37 | 38 | func (x *Schema) Reset() { 39 | *x = Schema{} 40 | if protoimpl.UnsafeEnabled { 41 | mi := &file_trpc_api_openapiv2_proto_msgTypes[0] 42 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 43 | ms.StoreMessageInfo(mi) 44 | } 45 | } 46 | 47 | func (x *Schema) String() string { 48 | return protoimpl.X.MessageStringOf(x) 49 | } 50 | 51 | func (*Schema) ProtoMessage() {} 52 | 53 | func (x *Schema) ProtoReflect() protoreflect.Message { 54 | mi := &file_trpc_api_openapiv2_proto_msgTypes[0] 55 | if protoimpl.UnsafeEnabled && x != nil { 56 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 57 | if ms.LoadMessageInfo() == nil { 58 | ms.StoreMessageInfo(mi) 59 | } 60 | return ms 61 | } 62 | return mi.MessageOf(x) 63 | } 64 | 65 | // Deprecated: Use Schema.ProtoReflect.Descriptor instead. 66 | func (*Schema) Descriptor() ([]byte, []int) { 67 | return file_trpc_api_openapiv2_proto_rawDescGZIP(), []int{0} 68 | } 69 | 70 | func (x *Schema) GetJsonSchema() *JSONSchema { 71 | if x != nil { 72 | return x.JsonSchema 73 | } 74 | return nil 75 | } 76 | 77 | // `JSONSchema` represents properties from JSON SCHEMA taken,and as used, in 78 | // the OpenAPI v2 spec. 79 | type JSONSchema struct { 80 | state protoimpl.MessageState 81 | sizeCache protoimpl.SizeCache 82 | unknownFields protoimpl.UnknownFields 83 | 84 | Required []string `protobuf:"bytes,1,rep,name=required,proto3" json:"required,omitempty"` 85 | } 86 | 87 | func (x *JSONSchema) Reset() { 88 | *x = JSONSchema{} 89 | if protoimpl.UnsafeEnabled { 90 | mi := &file_trpc_api_openapiv2_proto_msgTypes[1] 91 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 92 | ms.StoreMessageInfo(mi) 93 | } 94 | } 95 | 96 | func (x *JSONSchema) String() string { 97 | return protoimpl.X.MessageStringOf(x) 98 | } 99 | 100 | func (*JSONSchema) ProtoMessage() {} 101 | 102 | func (x *JSONSchema) ProtoReflect() protoreflect.Message { 103 | mi := &file_trpc_api_openapiv2_proto_msgTypes[1] 104 | if protoimpl.UnsafeEnabled && x != nil { 105 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 106 | if ms.LoadMessageInfo() == nil { 107 | ms.StoreMessageInfo(mi) 108 | } 109 | return ms 110 | } 111 | return mi.MessageOf(x) 112 | } 113 | 114 | // Deprecated: Use JSONSchema.ProtoReflect.Descriptor instead. 115 | func (*JSONSchema) Descriptor() ([]byte, []int) { 116 | return file_trpc_api_openapiv2_proto_rawDescGZIP(), []int{1} 117 | } 118 | 119 | func (x *JSONSchema) GetRequired() []string { 120 | if x != nil { 121 | return x.Required 122 | } 123 | return nil 124 | } 125 | 126 | var File_trpc_api_openapiv2_proto protoreflect.FileDescriptor 127 | 128 | var file_trpc_api_openapiv2_proto_rawDesc = []byte{ 129 | 0x0a, 0x18, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 130 | 0x70, 0x69, 0x76, 0x32, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x74, 0x72, 0x70, 0x63, 131 | 0x2e, 0x61, 0x70, 0x69, 0x22, 0x3f, 0x0a, 0x06, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x35, 132 | 0x0a, 0x0b, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x01, 0x20, 133 | 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4a, 134 | 0x53, 0x4f, 0x4e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x0a, 0x6a, 0x73, 0x6f, 0x6e, 0x53, 135 | 0x63, 0x68, 0x65, 0x6d, 0x61, 0x22, 0x28, 0x0a, 0x0a, 0x4a, 0x53, 0x4f, 0x4e, 0x53, 0x63, 0x68, 136 | 0x65, 0x6d, 0x61, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x18, 137 | 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x42, 138 | 0x4d, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x2e, 0x74, 139 | 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x65, 0x78, 0x74, 140 | 0x5a, 0x2c, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2f, 0x74, 0x72, 0x70, 141 | 0x63, 0x2f, 0x74, 0x72, 0x70, 0x63, 0x2d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 142 | 0x70, 0x62, 0x2f, 0x67, 0x6f, 0x2f, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x61, 0x70, 0x69, 0x62, 0x06, 143 | 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 144 | } 145 | 146 | var ( 147 | file_trpc_api_openapiv2_proto_rawDescOnce sync.Once 148 | file_trpc_api_openapiv2_proto_rawDescData = file_trpc_api_openapiv2_proto_rawDesc 149 | ) 150 | 151 | func file_trpc_api_openapiv2_proto_rawDescGZIP() []byte { 152 | file_trpc_api_openapiv2_proto_rawDescOnce.Do(func() { 153 | file_trpc_api_openapiv2_proto_rawDescData = protoimpl.X.CompressGZIP(file_trpc_api_openapiv2_proto_rawDescData) 154 | }) 155 | return file_trpc_api_openapiv2_proto_rawDescData 156 | } 157 | 158 | var file_trpc_api_openapiv2_proto_msgTypes = make([]protoimpl.MessageInfo, 2) 159 | var file_trpc_api_openapiv2_proto_goTypes = []interface{}{ 160 | (*Schema)(nil), // 0: trpc.api.Schema 161 | (*JSONSchema)(nil), // 1: trpc.api.JSONSchema 162 | } 163 | var file_trpc_api_openapiv2_proto_depIdxs = []int32{ 164 | 1, // 0: trpc.api.Schema.json_schema:type_name -> trpc.api.JSONSchema 165 | 1, // [1:1] is the sub-list for method output_type 166 | 1, // [1:1] is the sub-list for method input_type 167 | 1, // [1:1] is the sub-list for extension type_name 168 | 1, // [1:1] is the sub-list for extension extendee 169 | 0, // [0:1] is the sub-list for field type_name 170 | } 171 | 172 | func init() { file_trpc_api_openapiv2_proto_init() } 173 | func file_trpc_api_openapiv2_proto_init() { 174 | if File_trpc_api_openapiv2_proto != nil { 175 | return 176 | } 177 | if !protoimpl.UnsafeEnabled { 178 | file_trpc_api_openapiv2_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { 179 | switch v := v.(*Schema); i { 180 | case 0: 181 | return &v.state 182 | case 1: 183 | return &v.sizeCache 184 | case 2: 185 | return &v.unknownFields 186 | default: 187 | return nil 188 | } 189 | } 190 | file_trpc_api_openapiv2_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { 191 | switch v := v.(*JSONSchema); i { 192 | case 0: 193 | return &v.state 194 | case 1: 195 | return &v.sizeCache 196 | case 2: 197 | return &v.unknownFields 198 | default: 199 | return nil 200 | } 201 | } 202 | } 203 | type x struct{} 204 | out := protoimpl.TypeBuilder{ 205 | File: protoimpl.DescBuilder{ 206 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 207 | RawDescriptor: file_trpc_api_openapiv2_proto_rawDesc, 208 | NumEnums: 0, 209 | NumMessages: 2, 210 | NumExtensions: 0, 211 | NumServices: 0, 212 | }, 213 | GoTypes: file_trpc_api_openapiv2_proto_goTypes, 214 | DependencyIndexes: file_trpc_api_openapiv2_proto_depIdxs, 215 | MessageInfos: file_trpc_api_openapiv2_proto_msgTypes, 216 | }.Build() 217 | File_trpc_api_openapiv2_proto = out.File 218 | file_trpc_api_openapiv2_proto_rawDesc = nil 219 | file_trpc_api_openapiv2_proto_goTypes = nil 220 | file_trpc_api_openapiv2_proto_depIdxs = nil 221 | } 222 | -------------------------------------------------------------------------------- /pb/go/trpc/go.mod: -------------------------------------------------------------------------------- 1 | module trpc.group/trpc/trpc-protocol/pb/go/trpc 2 | 3 | go 1.16 4 | 5 | require google.golang.org/protobuf v1.36.6 6 | -------------------------------------------------------------------------------- /pb/go/trpc/go.sum: -------------------------------------------------------------------------------- 1 | github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= 2 | github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= 3 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 4 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= 5 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 6 | google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= 7 | google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= 8 | google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= 9 | -------------------------------------------------------------------------------- /pb/go/trpc/proto/trpc_options.pb.go: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making tRPC available. 2 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved. 3 | // If you have downloaded a copy of the tRPC source code from Tencent, 4 | // please note that tRPC source code is licensed under the Apache 2.0 License, 5 | // A copy of the Apache 2.0 License is included in this file. 6 | 7 | // Code generated by protoc-gen-go. DO NOT EDIT. 8 | // versions: 9 | // protoc-gen-go v1.28.1 10 | // protoc v5.27.1 11 | // source: trpc/proto/trpc_options.proto 12 | 13 | package proto 14 | 15 | import ( 16 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 17 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 18 | descriptorpb "google.golang.org/protobuf/types/descriptorpb" 19 | reflect "reflect" 20 | ) 21 | 22 | const ( 23 | // Verify that this generated code is sufficiently up-to-date. 24 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 25 | // Verify that runtime/protoimpl is sufficiently up-to-date. 26 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 27 | ) 28 | 29 | var file_trpc_proto_trpc_options_proto_extTypes = []protoimpl.ExtensionInfo{ 30 | { 31 | ExtendedType: (*descriptorpb.MethodOptions)(nil), 32 | ExtensionType: (*string)(nil), 33 | Field: 50001, 34 | Name: "trpc.alias", 35 | Tag: "bytes,50001,opt,name=alias", 36 | Filename: "trpc/proto/trpc_options.proto", 37 | }, 38 | { 39 | ExtendedType: (*descriptorpb.FieldOptions)(nil), 40 | ExtensionType: (*string)(nil), 41 | Field: 50050, 42 | Name: "trpc.go_tag", 43 | Tag: "bytes,50050,opt,name=go_tag", 44 | Filename: "trpc/proto/trpc_options.proto", 45 | }, 46 | } 47 | 48 | // Extension fields to descriptorpb.MethodOptions. 49 | var ( 50 | // optional string alias = 50001; 51 | E_Alias = &file_trpc_proto_trpc_options_proto_extTypes[0] 52 | ) 53 | 54 | // Extension fields to descriptorpb.FieldOptions. 55 | var ( 56 | // optional string go_tag = 50050; 57 | E_GoTag = &file_trpc_proto_trpc_options_proto_extTypes[1] 58 | ) 59 | 60 | var File_trpc_proto_trpc_options_proto protoreflect.FileDescriptor 61 | 62 | var file_trpc_proto_trpc_options_proto_rawDesc = []byte{ 63 | 0x0a, 0x1d, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x74, 0x72, 0x70, 64 | 0x63, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 65 | 0x04, 0x74, 0x72, 0x70, 0x63, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 66 | 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 67 | 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3a, 0x36, 0x0a, 0x05, 0x61, 0x6c, 0x69, 0x61, 0x73, 68 | 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 69 | 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 70 | 0x18, 0xd1, 0x86, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x3a, 71 | 0x36, 0x0a, 0x06, 0x67, 0x6f, 0x5f, 0x74, 0x61, 0x67, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 72 | 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 73 | 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x82, 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 74 | 0x52, 0x05, 0x67, 0x6f, 0x54, 0x61, 0x67, 0x42, 0x4f, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 75 | 0x65, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x2e, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 76 | 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x65, 0x78, 0x74, 0x5a, 0x2e, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x67, 77 | 0x72, 0x6f, 0x75, 0x70, 0x2f, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x74, 0x72, 0x70, 0x63, 0x2d, 0x70, 78 | 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x70, 0x62, 0x2f, 0x67, 0x6f, 0x2f, 0x74, 0x72, 79 | 0x70, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 80 | } 81 | 82 | var file_trpc_proto_trpc_options_proto_goTypes = []interface{}{ 83 | (*descriptorpb.MethodOptions)(nil), // 0: google.protobuf.MethodOptions 84 | (*descriptorpb.FieldOptions)(nil), // 1: google.protobuf.FieldOptions 85 | } 86 | var file_trpc_proto_trpc_options_proto_depIdxs = []int32{ 87 | 0, // 0: trpc.alias:extendee -> google.protobuf.MethodOptions 88 | 1, // 1: trpc.go_tag:extendee -> google.protobuf.FieldOptions 89 | 2, // [2:2] is the sub-list for method output_type 90 | 2, // [2:2] is the sub-list for method input_type 91 | 2, // [2:2] is the sub-list for extension type_name 92 | 0, // [0:2] is the sub-list for extension extendee 93 | 0, // [0:0] is the sub-list for field type_name 94 | } 95 | 96 | func init() { file_trpc_proto_trpc_options_proto_init() } 97 | func file_trpc_proto_trpc_options_proto_init() { 98 | if File_trpc_proto_trpc_options_proto != nil { 99 | return 100 | } 101 | type x struct{} 102 | out := protoimpl.TypeBuilder{ 103 | File: protoimpl.DescBuilder{ 104 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 105 | RawDescriptor: file_trpc_proto_trpc_options_proto_rawDesc, 106 | NumEnums: 0, 107 | NumMessages: 0, 108 | NumExtensions: 2, 109 | NumServices: 0, 110 | }, 111 | GoTypes: file_trpc_proto_trpc_options_proto_goTypes, 112 | DependencyIndexes: file_trpc_proto_trpc_options_proto_depIdxs, 113 | ExtensionInfos: file_trpc_proto_trpc_options_proto_extTypes, 114 | }.Build() 115 | File_trpc_proto_trpc_options_proto = out.File 116 | file_trpc_proto_trpc_options_proto_rawDesc = nil 117 | file_trpc_proto_trpc_options_proto_goTypes = nil 118 | file_trpc_proto_trpc_options_proto_depIdxs = nil 119 | } 120 | -------------------------------------------------------------------------------- /pb/go/trpc/swagger/swagger.pb.go: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making tRPC available. 2 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved. 3 | // If you have downloaded a copy of the tRPC source code from Tencent, 4 | // please note that tRPC source code is licensed under the Apache 2.0 License, 5 | // A copy of the Apache 2.0 License is included in this file. 6 | 7 | // Code generated by protoc-gen-go. DO NOT EDIT. 8 | // versions: 9 | // protoc-gen-go v1.28.1 10 | // protoc v5.27.1 11 | // source: trpc/swagger/swagger.proto 12 | 13 | package swagger 14 | 15 | import ( 16 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 17 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 18 | descriptorpb "google.golang.org/protobuf/types/descriptorpb" 19 | reflect "reflect" 20 | sync "sync" 21 | ) 22 | 23 | const ( 24 | // Verify that this generated code is sufficiently up-to-date. 25 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 26 | // Verify that runtime/protoimpl is sufficiently up-to-date. 27 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 28 | ) 29 | 30 | // to gen swagger json 31 | type SwaggerRule struct { 32 | state protoimpl.MessageState 33 | sizeCache protoimpl.SizeCache 34 | unknownFields protoimpl.UnknownFields 35 | 36 | Title string `protobuf:"bytes,50103,opt,name=title,proto3" json:"title,omitempty"` 37 | Method string `protobuf:"bytes,50104,opt,name=method,proto3" json:"method,omitempty"` 38 | Description string `protobuf:"bytes,50105,opt,name=description,proto3" json:"description,omitempty"` 39 | Params []*SwaggerParam `protobuf:"bytes,50106,rep,name=params,proto3" json:"params,omitempty"` 40 | } 41 | 42 | func (x *SwaggerRule) Reset() { 43 | *x = SwaggerRule{} 44 | if protoimpl.UnsafeEnabled { 45 | mi := &file_trpc_swagger_swagger_proto_msgTypes[0] 46 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 47 | ms.StoreMessageInfo(mi) 48 | } 49 | } 50 | 51 | func (x *SwaggerRule) String() string { 52 | return protoimpl.X.MessageStringOf(x) 53 | } 54 | 55 | func (*SwaggerRule) ProtoMessage() {} 56 | 57 | func (x *SwaggerRule) ProtoReflect() protoreflect.Message { 58 | mi := &file_trpc_swagger_swagger_proto_msgTypes[0] 59 | if protoimpl.UnsafeEnabled && x != nil { 60 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 61 | if ms.LoadMessageInfo() == nil { 62 | ms.StoreMessageInfo(mi) 63 | } 64 | return ms 65 | } 66 | return mi.MessageOf(x) 67 | } 68 | 69 | // Deprecated: Use SwaggerRule.ProtoReflect.Descriptor instead. 70 | func (*SwaggerRule) Descriptor() ([]byte, []int) { 71 | return file_trpc_swagger_swagger_proto_rawDescGZIP(), []int{0} 72 | } 73 | 74 | func (x *SwaggerRule) GetTitle() string { 75 | if x != nil { 76 | return x.Title 77 | } 78 | return "" 79 | } 80 | 81 | func (x *SwaggerRule) GetMethod() string { 82 | if x != nil { 83 | return x.Method 84 | } 85 | return "" 86 | } 87 | 88 | func (x *SwaggerRule) GetDescription() string { 89 | if x != nil { 90 | return x.Description 91 | } 92 | return "" 93 | } 94 | 95 | func (x *SwaggerRule) GetParams() []*SwaggerParam { 96 | if x != nil { 97 | return x.Params 98 | } 99 | return nil 100 | } 101 | 102 | type SwaggerParam struct { 103 | state protoimpl.MessageState 104 | sizeCache protoimpl.SizeCache 105 | unknownFields protoimpl.UnknownFields 106 | 107 | Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` 108 | Required bool `protobuf:"varint,2,opt,name=required,proto3" json:"required,omitempty"` 109 | Default string `protobuf:"bytes,3,opt,name=default,proto3" json:"default,omitempty"` 110 | } 111 | 112 | func (x *SwaggerParam) Reset() { 113 | *x = SwaggerParam{} 114 | if protoimpl.UnsafeEnabled { 115 | mi := &file_trpc_swagger_swagger_proto_msgTypes[1] 116 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 117 | ms.StoreMessageInfo(mi) 118 | } 119 | } 120 | 121 | func (x *SwaggerParam) String() string { 122 | return protoimpl.X.MessageStringOf(x) 123 | } 124 | 125 | func (*SwaggerParam) ProtoMessage() {} 126 | 127 | func (x *SwaggerParam) ProtoReflect() protoreflect.Message { 128 | mi := &file_trpc_swagger_swagger_proto_msgTypes[1] 129 | if protoimpl.UnsafeEnabled && x != nil { 130 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 131 | if ms.LoadMessageInfo() == nil { 132 | ms.StoreMessageInfo(mi) 133 | } 134 | return ms 135 | } 136 | return mi.MessageOf(x) 137 | } 138 | 139 | // Deprecated: Use SwaggerParam.ProtoReflect.Descriptor instead. 140 | func (*SwaggerParam) Descriptor() ([]byte, []int) { 141 | return file_trpc_swagger_swagger_proto_rawDescGZIP(), []int{1} 142 | } 143 | 144 | func (x *SwaggerParam) GetName() string { 145 | if x != nil { 146 | return x.Name 147 | } 148 | return "" 149 | } 150 | 151 | func (x *SwaggerParam) GetRequired() bool { 152 | if x != nil { 153 | return x.Required 154 | } 155 | return false 156 | } 157 | 158 | func (x *SwaggerParam) GetDefault() string { 159 | if x != nil { 160 | return x.Default 161 | } 162 | return "" 163 | } 164 | 165 | var file_trpc_swagger_swagger_proto_extTypes = []protoimpl.ExtensionInfo{ 166 | { 167 | ExtendedType: (*descriptorpb.MethodOptions)(nil), 168 | ExtensionType: (*SwaggerRule)(nil), 169 | Field: 50101, 170 | Name: "trpc.swagger", 171 | Tag: "bytes,50101,opt,name=swagger", 172 | Filename: "trpc/swagger/swagger.proto", 173 | }, 174 | } 175 | 176 | // Extension fields to descriptorpb.MethodOptions. 177 | var ( 178 | // optional trpc.SwaggerRule swagger = 50101; 179 | E_Swagger = &file_trpc_swagger_swagger_proto_extTypes[0] 180 | ) 181 | 182 | var File_trpc_swagger_swagger_proto protoreflect.FileDescriptor 183 | 184 | var file_trpc_swagger_swagger_proto_rawDesc = []byte{ 185 | 0x0a, 0x1a, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2f, 0x73, 186 | 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x74, 0x72, 187 | 0x70, 0x63, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 188 | 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 189 | 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x91, 0x01, 0x0a, 0x0b, 0x53, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 190 | 0x52, 0x75, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0xb7, 0x87, 191 | 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x06, 192 | 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0xb8, 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 193 | 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x22, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 194 | 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xb9, 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 195 | 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2c, 0x0a, 0x06, 0x70, 0x61, 196 | 0x72, 0x61, 0x6d, 0x73, 0x18, 0xba, 0x87, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x74, 197 | 0x72, 0x70, 0x63, 0x2e, 0x53, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x50, 0x61, 0x72, 0x61, 0x6d, 198 | 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x58, 0x0a, 0x0c, 0x53, 0x77, 0x61, 0x67, 199 | 0x67, 0x65, 0x72, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 200 | 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 201 | 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 202 | 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x66, 0x61, 203 | 0x75, 0x6c, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 204 | 0x6c, 0x74, 0x3a, 0x4d, 0x0a, 0x07, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x12, 0x1e, 0x2e, 205 | 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 206 | 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xb5, 0x87, 207 | 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x77, 0x61, 208 | 0x67, 0x67, 0x65, 0x72, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x07, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 209 | 0x72, 0x42, 0x51, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, 0x63, 0x65, 0x6e, 0x74, 210 | 0x2e, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x65, 211 | 0x78, 0x74, 0x5a, 0x30, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2f, 0x74, 212 | 0x72, 0x70, 0x63, 0x2f, 0x74, 0x72, 0x70, 0x63, 0x2d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 213 | 0x6c, 0x2f, 0x70, 0x62, 0x2f, 0x67, 0x6f, 0x2f, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x73, 0x77, 0x61, 214 | 0x67, 0x67, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 215 | } 216 | 217 | var ( 218 | file_trpc_swagger_swagger_proto_rawDescOnce sync.Once 219 | file_trpc_swagger_swagger_proto_rawDescData = file_trpc_swagger_swagger_proto_rawDesc 220 | ) 221 | 222 | func file_trpc_swagger_swagger_proto_rawDescGZIP() []byte { 223 | file_trpc_swagger_swagger_proto_rawDescOnce.Do(func() { 224 | file_trpc_swagger_swagger_proto_rawDescData = protoimpl.X.CompressGZIP(file_trpc_swagger_swagger_proto_rawDescData) 225 | }) 226 | return file_trpc_swagger_swagger_proto_rawDescData 227 | } 228 | 229 | var file_trpc_swagger_swagger_proto_msgTypes = make([]protoimpl.MessageInfo, 2) 230 | var file_trpc_swagger_swagger_proto_goTypes = []interface{}{ 231 | (*SwaggerRule)(nil), // 0: trpc.SwaggerRule 232 | (*SwaggerParam)(nil), // 1: trpc.SwaggerParam 233 | (*descriptorpb.MethodOptions)(nil), // 2: google.protobuf.MethodOptions 234 | } 235 | var file_trpc_swagger_swagger_proto_depIdxs = []int32{ 236 | 1, // 0: trpc.SwaggerRule.params:type_name -> trpc.SwaggerParam 237 | 2, // 1: trpc.swagger:extendee -> google.protobuf.MethodOptions 238 | 0, // 2: trpc.swagger:type_name -> trpc.SwaggerRule 239 | 3, // [3:3] is the sub-list for method output_type 240 | 3, // [3:3] is the sub-list for method input_type 241 | 2, // [2:3] is the sub-list for extension type_name 242 | 1, // [1:2] is the sub-list for extension extendee 243 | 0, // [0:1] is the sub-list for field type_name 244 | } 245 | 246 | func init() { file_trpc_swagger_swagger_proto_init() } 247 | func file_trpc_swagger_swagger_proto_init() { 248 | if File_trpc_swagger_swagger_proto != nil { 249 | return 250 | } 251 | if !protoimpl.UnsafeEnabled { 252 | file_trpc_swagger_swagger_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { 253 | switch v := v.(*SwaggerRule); i { 254 | case 0: 255 | return &v.state 256 | case 1: 257 | return &v.sizeCache 258 | case 2: 259 | return &v.unknownFields 260 | default: 261 | return nil 262 | } 263 | } 264 | file_trpc_swagger_swagger_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { 265 | switch v := v.(*SwaggerParam); i { 266 | case 0: 267 | return &v.state 268 | case 1: 269 | return &v.sizeCache 270 | case 2: 271 | return &v.unknownFields 272 | default: 273 | return nil 274 | } 275 | } 276 | } 277 | type x struct{} 278 | out := protoimpl.TypeBuilder{ 279 | File: protoimpl.DescBuilder{ 280 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 281 | RawDescriptor: file_trpc_swagger_swagger_proto_rawDesc, 282 | NumEnums: 0, 283 | NumMessages: 2, 284 | NumExtensions: 1, 285 | NumServices: 0, 286 | }, 287 | GoTypes: file_trpc_swagger_swagger_proto_goTypes, 288 | DependencyIndexes: file_trpc_swagger_swagger_proto_depIdxs, 289 | MessageInfos: file_trpc_swagger_swagger_proto_msgTypes, 290 | ExtensionInfos: file_trpc_swagger_swagger_proto_extTypes, 291 | }.Build() 292 | File_trpc_swagger_swagger_proto = out.File 293 | file_trpc_swagger_swagger_proto_rawDesc = nil 294 | file_trpc_swagger_swagger_proto_goTypes = nil 295 | file_trpc_swagger_swagger_proto_depIdxs = nil 296 | } 297 | -------------------------------------------------------------------------------- /pb/go/trpc/v2/api/annotations.pb.go: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making tRPC available. 2 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved. 3 | // If you have downloaded a copy of the tRPC source code from Tencent, 4 | // please note that tRPC source code is licensed under the Apache 2.0 License, 5 | // A copy of the Apache 2.0 License is included in this file. 6 | 7 | // Code generated by protoc-gen-go. DO NOT EDIT. 8 | // versions: 9 | // protoc-gen-go v1.28.1 10 | // protoc v5.27.1 11 | // source: trpc/v2/api/annotations.proto 12 | 13 | package api 14 | 15 | import ( 16 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 17 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 18 | descriptorpb "google.golang.org/protobuf/types/descriptorpb" 19 | reflect "reflect" 20 | ) 21 | 22 | const ( 23 | // Verify that this generated code is sufficiently up-to-date. 24 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 25 | // Verify that runtime/protoimpl is sufficiently up-to-date. 26 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 27 | ) 28 | 29 | var file_trpc_v2_api_annotations_proto_extTypes = []protoimpl.ExtensionInfo{ 30 | { 31 | ExtendedType: (*descriptorpb.MethodOptions)(nil), 32 | ExtensionType: (*HttpRule)(nil), 33 | Field: 1157, 34 | Name: "trpc.v2.api.http", 35 | Tag: "bytes,1157,opt,name=http", 36 | Filename: "trpc/v2/api/annotations.proto", 37 | }, 38 | } 39 | 40 | // Extension fields to descriptorpb.MethodOptions. 41 | var ( 42 | // optional trpc.v2.api.HttpRule http = 1157; 43 | E_Http = &file_trpc_v2_api_annotations_proto_extTypes[0] 44 | ) 45 | 46 | var File_trpc_v2_api_annotations_proto protoreflect.FileDescriptor 47 | 48 | var file_trpc_v2_api_annotations_proto_rawDesc = []byte{ 49 | 0x0a, 0x1d, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x32, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 50 | 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 51 | 0x0b, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x32, 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x16, 0x74, 0x72, 52 | 0x70, 0x63, 0x2f, 0x76, 0x32, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x70, 53 | 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 54 | 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 55 | 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3a, 0x4a, 0x0a, 0x04, 0x68, 0x74, 0x74, 0x70, 0x12, 0x1e, 56 | 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 57 | 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x85, 58 | 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x32, 0x2e, 59 | 0x61, 0x70, 0x69, 0x2e, 0x48, 0x74, 0x74, 0x70, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x04, 0x68, 0x74, 60 | 0x74, 0x70, 0x42, 0x50, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, 0x63, 0x65, 0x6e, 61 | 0x74, 0x2e, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 62 | 0x65, 0x78, 0x74, 0x5a, 0x2f, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2f, 63 | 0x74, 0x72, 0x70, 0x63, 0x2f, 0x74, 0x72, 0x70, 0x63, 0x2d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 64 | 0x6f, 0x6c, 0x2f, 0x70, 0x62, 0x2f, 0x67, 0x6f, 0x2f, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x32, 65 | 0x2f, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 66 | } 67 | 68 | var file_trpc_v2_api_annotations_proto_goTypes = []interface{}{ 69 | (*descriptorpb.MethodOptions)(nil), // 0: google.protobuf.MethodOptions 70 | (*HttpRule)(nil), // 1: trpc.v2.api.HttpRule 71 | } 72 | var file_trpc_v2_api_annotations_proto_depIdxs = []int32{ 73 | 0, // 0: trpc.v2.api.http:extendee -> google.protobuf.MethodOptions 74 | 1, // 1: trpc.v2.api.http:type_name -> trpc.v2.api.HttpRule 75 | 2, // [2:2] is the sub-list for method output_type 76 | 2, // [2:2] is the sub-list for method input_type 77 | 1, // [1:2] is the sub-list for extension type_name 78 | 0, // [0:1] is the sub-list for extension extendee 79 | 0, // [0:0] is the sub-list for field type_name 80 | } 81 | 82 | func init() { file_trpc_v2_api_annotations_proto_init() } 83 | func file_trpc_v2_api_annotations_proto_init() { 84 | if File_trpc_v2_api_annotations_proto != nil { 85 | return 86 | } 87 | file_trpc_v2_api_http_proto_init() 88 | type x struct{} 89 | out := protoimpl.TypeBuilder{ 90 | File: protoimpl.DescBuilder{ 91 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 92 | RawDescriptor: file_trpc_v2_api_annotations_proto_rawDesc, 93 | NumEnums: 0, 94 | NumMessages: 0, 95 | NumExtensions: 1, 96 | NumServices: 0, 97 | }, 98 | GoTypes: file_trpc_v2_api_annotations_proto_goTypes, 99 | DependencyIndexes: file_trpc_v2_api_annotations_proto_depIdxs, 100 | ExtensionInfos: file_trpc_v2_api_annotations_proto_extTypes, 101 | }.Build() 102 | File_trpc_v2_api_annotations_proto = out.File 103 | file_trpc_v2_api_annotations_proto_rawDesc = nil 104 | file_trpc_v2_api_annotations_proto_goTypes = nil 105 | file_trpc_v2_api_annotations_proto_depIdxs = nil 106 | } 107 | -------------------------------------------------------------------------------- /pb/go/trpc/v2/api/http.pb.go: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making tRPC available. 2 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved. 3 | // If you have downloaded a copy of the tRPC source code from Tencent, 4 | // please note that tRPC source code is licensed under the Apache 2.0 License, 5 | // A copy of the Apache 2.0 License is included in this file. 6 | 7 | // Code generated by protoc-gen-go. DO NOT EDIT. 8 | // versions: 9 | // protoc-gen-go v1.28.1 10 | // protoc v5.27.1 11 | // source: trpc/v2/api/http.proto 12 | 13 | package api 14 | 15 | import ( 16 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 17 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 18 | reflect "reflect" 19 | sync "sync" 20 | ) 21 | 22 | const ( 23 | // Verify that this generated code is sufficiently up-to-date. 24 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 25 | // Verify that runtime/protoimpl is sufficiently up-to-date. 26 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 27 | ) 28 | 29 | type HttpRule struct { 30 | state protoimpl.MessageState 31 | sizeCache protoimpl.SizeCache 32 | unknownFields protoimpl.UnknownFields 33 | 34 | // Selects a method to which this rule applies. 35 | // 36 | // Refer to [selector][google.api.DocumentationRule.selector] for syntax details. 37 | Selector string `protobuf:"bytes,1,opt,name=selector,proto3" json:"selector,omitempty"` 38 | // Determines the URL pattern is matched by this rules. This pattern can be 39 | // used with any of the {get|put|post|delete|patch} methods. A custom method 40 | // can be defined using the 'custom' field. 41 | // 42 | // Types that are assignable to Pattern: 43 | // *HttpRule_Get 44 | // *HttpRule_Put 45 | // *HttpRule_Post 46 | // *HttpRule_Delete 47 | // *HttpRule_Patch 48 | // *HttpRule_Custom 49 | Pattern isHttpRule_Pattern `protobuf_oneof:"pattern"` 50 | // The name of the request field whose value is mapped to the HTTP request 51 | // body, or `*` for mapping all request fields not captured by the path 52 | // pattern to the HTTP body, or omitted for not having any HTTP request body. 53 | // 54 | // NOTE: the referred field must be present at the top-level of the request 55 | // message type. 56 | Body string `protobuf:"bytes,7,opt,name=body,proto3" json:"body,omitempty"` 57 | // Optional. The name of the response field whose value is mapped to the HTTP 58 | // response body. When omitted, the entire response message will be used 59 | // as the HTTP response body. 60 | // 61 | // NOTE: The referred field must be present at the top-level of the response 62 | // message type. 63 | ResponseBody string `protobuf:"bytes,12,opt,name=response_body,json=responseBody,proto3" json:"response_body,omitempty"` 64 | // Additional HTTP bindings for the selector. Nested bindings must 65 | // not contain an `additional_bindings` field themselves (that is, 66 | // the nesting may only be one level deep). 67 | AdditionalBindings []*HttpRule `protobuf:"bytes,11,rep,name=additional_bindings,json=additionalBindings,proto3" json:"additional_bindings,omitempty"` 68 | } 69 | 70 | func (x *HttpRule) Reset() { 71 | *x = HttpRule{} 72 | if protoimpl.UnsafeEnabled { 73 | mi := &file_trpc_v2_api_http_proto_msgTypes[0] 74 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 75 | ms.StoreMessageInfo(mi) 76 | } 77 | } 78 | 79 | func (x *HttpRule) String() string { 80 | return protoimpl.X.MessageStringOf(x) 81 | } 82 | 83 | func (*HttpRule) ProtoMessage() {} 84 | 85 | func (x *HttpRule) ProtoReflect() protoreflect.Message { 86 | mi := &file_trpc_v2_api_http_proto_msgTypes[0] 87 | if protoimpl.UnsafeEnabled && x != nil { 88 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 89 | if ms.LoadMessageInfo() == nil { 90 | ms.StoreMessageInfo(mi) 91 | } 92 | return ms 93 | } 94 | return mi.MessageOf(x) 95 | } 96 | 97 | // Deprecated: Use HttpRule.ProtoReflect.Descriptor instead. 98 | func (*HttpRule) Descriptor() ([]byte, []int) { 99 | return file_trpc_v2_api_http_proto_rawDescGZIP(), []int{0} 100 | } 101 | 102 | func (x *HttpRule) GetSelector() string { 103 | if x != nil { 104 | return x.Selector 105 | } 106 | return "" 107 | } 108 | 109 | func (m *HttpRule) GetPattern() isHttpRule_Pattern { 110 | if m != nil { 111 | return m.Pattern 112 | } 113 | return nil 114 | } 115 | 116 | func (x *HttpRule) GetGet() string { 117 | if x, ok := x.GetPattern().(*HttpRule_Get); ok { 118 | return x.Get 119 | } 120 | return "" 121 | } 122 | 123 | func (x *HttpRule) GetPut() string { 124 | if x, ok := x.GetPattern().(*HttpRule_Put); ok { 125 | return x.Put 126 | } 127 | return "" 128 | } 129 | 130 | func (x *HttpRule) GetPost() string { 131 | if x, ok := x.GetPattern().(*HttpRule_Post); ok { 132 | return x.Post 133 | } 134 | return "" 135 | } 136 | 137 | func (x *HttpRule) GetDelete() string { 138 | if x, ok := x.GetPattern().(*HttpRule_Delete); ok { 139 | return x.Delete 140 | } 141 | return "" 142 | } 143 | 144 | func (x *HttpRule) GetPatch() string { 145 | if x, ok := x.GetPattern().(*HttpRule_Patch); ok { 146 | return x.Patch 147 | } 148 | return "" 149 | } 150 | 151 | func (x *HttpRule) GetCustom() *CustomHttpPattern { 152 | if x, ok := x.GetPattern().(*HttpRule_Custom); ok { 153 | return x.Custom 154 | } 155 | return nil 156 | } 157 | 158 | func (x *HttpRule) GetBody() string { 159 | if x != nil { 160 | return x.Body 161 | } 162 | return "" 163 | } 164 | 165 | func (x *HttpRule) GetResponseBody() string { 166 | if x != nil { 167 | return x.ResponseBody 168 | } 169 | return "" 170 | } 171 | 172 | func (x *HttpRule) GetAdditionalBindings() []*HttpRule { 173 | if x != nil { 174 | return x.AdditionalBindings 175 | } 176 | return nil 177 | } 178 | 179 | type isHttpRule_Pattern interface { 180 | isHttpRule_Pattern() 181 | } 182 | 183 | type HttpRule_Get struct { 184 | // Maps to HTTP GET. Used for listing and getting information about 185 | // resources. 186 | Get string `protobuf:"bytes,2,opt,name=get,proto3,oneof"` 187 | } 188 | 189 | type HttpRule_Put struct { 190 | // Maps to HTTP PUT. Used for replacing a resource. 191 | Put string `protobuf:"bytes,3,opt,name=put,proto3,oneof"` 192 | } 193 | 194 | type HttpRule_Post struct { 195 | // Maps to HTTP POST. Used for creating a resource or performing an action. 196 | Post string `protobuf:"bytes,4,opt,name=post,proto3,oneof"` 197 | } 198 | 199 | type HttpRule_Delete struct { 200 | // Maps to HTTP DELETE. Used for deleting a resource. 201 | Delete string `protobuf:"bytes,5,opt,name=delete,proto3,oneof"` 202 | } 203 | 204 | type HttpRule_Patch struct { 205 | // Maps to HTTP PATCH. Used for updating a resource. 206 | Patch string `protobuf:"bytes,6,opt,name=patch,proto3,oneof"` 207 | } 208 | 209 | type HttpRule_Custom struct { 210 | // The custom pattern is used for specifying an HTTP method that is not 211 | // included in the `pattern` field, such as HEAD, or "*" to leave the 212 | // HTTP method unspecified for this rule. The wild-card rule is useful 213 | // for services that provide content to Web (HTML) clients. 214 | Custom *CustomHttpPattern `protobuf:"bytes,8,opt,name=custom,proto3,oneof"` 215 | } 216 | 217 | func (*HttpRule_Get) isHttpRule_Pattern() {} 218 | 219 | func (*HttpRule_Put) isHttpRule_Pattern() {} 220 | 221 | func (*HttpRule_Post) isHttpRule_Pattern() {} 222 | 223 | func (*HttpRule_Delete) isHttpRule_Pattern() {} 224 | 225 | func (*HttpRule_Patch) isHttpRule_Pattern() {} 226 | 227 | func (*HttpRule_Custom) isHttpRule_Pattern() {} 228 | 229 | // A custom pattern is used for defining custom HTTP verb. 230 | type CustomHttpPattern struct { 231 | state protoimpl.MessageState 232 | sizeCache protoimpl.SizeCache 233 | unknownFields protoimpl.UnknownFields 234 | 235 | // The name of this custom HTTP verb. 236 | Kind string `protobuf:"bytes,1,opt,name=kind,proto3" json:"kind,omitempty"` 237 | // The path matched by this custom verb. 238 | Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` 239 | } 240 | 241 | func (x *CustomHttpPattern) Reset() { 242 | *x = CustomHttpPattern{} 243 | if protoimpl.UnsafeEnabled { 244 | mi := &file_trpc_v2_api_http_proto_msgTypes[1] 245 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 246 | ms.StoreMessageInfo(mi) 247 | } 248 | } 249 | 250 | func (x *CustomHttpPattern) String() string { 251 | return protoimpl.X.MessageStringOf(x) 252 | } 253 | 254 | func (*CustomHttpPattern) ProtoMessage() {} 255 | 256 | func (x *CustomHttpPattern) ProtoReflect() protoreflect.Message { 257 | mi := &file_trpc_v2_api_http_proto_msgTypes[1] 258 | if protoimpl.UnsafeEnabled && x != nil { 259 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 260 | if ms.LoadMessageInfo() == nil { 261 | ms.StoreMessageInfo(mi) 262 | } 263 | return ms 264 | } 265 | return mi.MessageOf(x) 266 | } 267 | 268 | // Deprecated: Use CustomHttpPattern.ProtoReflect.Descriptor instead. 269 | func (*CustomHttpPattern) Descriptor() ([]byte, []int) { 270 | return file_trpc_v2_api_http_proto_rawDescGZIP(), []int{1} 271 | } 272 | 273 | func (x *CustomHttpPattern) GetKind() string { 274 | if x != nil { 275 | return x.Kind 276 | } 277 | return "" 278 | } 279 | 280 | func (x *CustomHttpPattern) GetPath() string { 281 | if x != nil { 282 | return x.Path 283 | } 284 | return "" 285 | } 286 | 287 | var File_trpc_v2_api_http_proto protoreflect.FileDescriptor 288 | 289 | var file_trpc_v2_api_http_proto_rawDesc = []byte{ 290 | 0x0a, 0x16, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x32, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x68, 0x74, 291 | 0x74, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x76, 292 | 0x32, 0x2e, 0x61, 0x70, 0x69, 0x22, 0xdc, 0x02, 0x0a, 0x08, 0x48, 0x74, 0x74, 0x70, 0x52, 0x75, 293 | 0x6c, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x01, 294 | 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x12, 295 | 0x0a, 0x03, 0x67, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x03, 0x67, 296 | 0x65, 0x74, 0x12, 0x12, 0x0a, 0x03, 0x70, 0x75, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 297 | 0x00, 0x52, 0x03, 0x70, 0x75, 0x74, 0x12, 0x14, 0x0a, 0x04, 0x70, 0x6f, 0x73, 0x74, 0x18, 0x04, 298 | 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x04, 0x70, 0x6f, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x06, 299 | 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x06, 300 | 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x16, 0x0a, 0x05, 0x70, 0x61, 0x74, 0x63, 0x68, 0x18, 301 | 0x06, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x05, 0x70, 0x61, 0x74, 0x63, 0x68, 0x12, 0x38, 302 | 0x0a, 0x06, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 303 | 0x2e, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x32, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x75, 0x73, 304 | 0x74, 0x6f, 0x6d, 0x48, 0x74, 0x74, 0x70, 0x50, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x48, 0x00, 305 | 0x52, 0x06, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 306 | 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x23, 0x0a, 0x0d, 307 | 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x0c, 0x20, 308 | 0x01, 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 309 | 0x79, 0x12, 0x46, 0x0a, 0x13, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 310 | 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 311 | 0x2e, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x32, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x48, 0x74, 0x74, 312 | 0x70, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x12, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 313 | 0x6c, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x74, 314 | 0x74, 0x65, 0x72, 0x6e, 0x22, 0x3b, 0x0a, 0x11, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x48, 0x74, 315 | 0x74, 0x70, 0x50, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 316 | 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x12, 0x0a, 317 | 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 318 | 0x68, 0x42, 0x50, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, 0x63, 0x65, 0x6e, 0x74, 319 | 0x2e, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x65, 320 | 0x78, 0x74, 0x5a, 0x2f, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2f, 0x74, 321 | 0x72, 0x70, 0x63, 0x2f, 0x74, 0x72, 0x70, 0x63, 0x2d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 322 | 0x6c, 0x2f, 0x70, 0x62, 0x2f, 0x67, 0x6f, 0x2f, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x32, 0x2f, 323 | 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 324 | } 325 | 326 | var ( 327 | file_trpc_v2_api_http_proto_rawDescOnce sync.Once 328 | file_trpc_v2_api_http_proto_rawDescData = file_trpc_v2_api_http_proto_rawDesc 329 | ) 330 | 331 | func file_trpc_v2_api_http_proto_rawDescGZIP() []byte { 332 | file_trpc_v2_api_http_proto_rawDescOnce.Do(func() { 333 | file_trpc_v2_api_http_proto_rawDescData = protoimpl.X.CompressGZIP(file_trpc_v2_api_http_proto_rawDescData) 334 | }) 335 | return file_trpc_v2_api_http_proto_rawDescData 336 | } 337 | 338 | var file_trpc_v2_api_http_proto_msgTypes = make([]protoimpl.MessageInfo, 2) 339 | var file_trpc_v2_api_http_proto_goTypes = []interface{}{ 340 | (*HttpRule)(nil), // 0: trpc.v2.api.HttpRule 341 | (*CustomHttpPattern)(nil), // 1: trpc.v2.api.CustomHttpPattern 342 | } 343 | var file_trpc_v2_api_http_proto_depIdxs = []int32{ 344 | 1, // 0: trpc.v2.api.HttpRule.custom:type_name -> trpc.v2.api.CustomHttpPattern 345 | 0, // 1: trpc.v2.api.HttpRule.additional_bindings:type_name -> trpc.v2.api.HttpRule 346 | 2, // [2:2] is the sub-list for method output_type 347 | 2, // [2:2] is the sub-list for method input_type 348 | 2, // [2:2] is the sub-list for extension type_name 349 | 2, // [2:2] is the sub-list for extension extendee 350 | 0, // [0:2] is the sub-list for field type_name 351 | } 352 | 353 | func init() { file_trpc_v2_api_http_proto_init() } 354 | func file_trpc_v2_api_http_proto_init() { 355 | if File_trpc_v2_api_http_proto != nil { 356 | return 357 | } 358 | if !protoimpl.UnsafeEnabled { 359 | file_trpc_v2_api_http_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { 360 | switch v := v.(*HttpRule); i { 361 | case 0: 362 | return &v.state 363 | case 1: 364 | return &v.sizeCache 365 | case 2: 366 | return &v.unknownFields 367 | default: 368 | return nil 369 | } 370 | } 371 | file_trpc_v2_api_http_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { 372 | switch v := v.(*CustomHttpPattern); i { 373 | case 0: 374 | return &v.state 375 | case 1: 376 | return &v.sizeCache 377 | case 2: 378 | return &v.unknownFields 379 | default: 380 | return nil 381 | } 382 | } 383 | } 384 | file_trpc_v2_api_http_proto_msgTypes[0].OneofWrappers = []interface{}{ 385 | (*HttpRule_Get)(nil), 386 | (*HttpRule_Put)(nil), 387 | (*HttpRule_Post)(nil), 388 | (*HttpRule_Delete)(nil), 389 | (*HttpRule_Patch)(nil), 390 | (*HttpRule_Custom)(nil), 391 | } 392 | type x struct{} 393 | out := protoimpl.TypeBuilder{ 394 | File: protoimpl.DescBuilder{ 395 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 396 | RawDescriptor: file_trpc_v2_api_http_proto_rawDesc, 397 | NumEnums: 0, 398 | NumMessages: 2, 399 | NumExtensions: 0, 400 | NumServices: 0, 401 | }, 402 | GoTypes: file_trpc_v2_api_http_proto_goTypes, 403 | DependencyIndexes: file_trpc_v2_api_http_proto_depIdxs, 404 | MessageInfos: file_trpc_v2_api_http_proto_msgTypes, 405 | }.Build() 406 | File_trpc_v2_api_http_proto = out.File 407 | file_trpc_v2_api_http_proto_rawDesc = nil 408 | file_trpc_v2_api_http_proto_goTypes = nil 409 | file_trpc_v2_api_http_proto_depIdxs = nil 410 | } 411 | -------------------------------------------------------------------------------- /pb/go/trpc/v2/go.mod: -------------------------------------------------------------------------------- 1 | module trpc.group/trpc/trpc-protocol/pb/go/trpc/v2 2 | 3 | go 1.16 4 | 5 | require google.golang.org/protobuf v1.36.6 6 | -------------------------------------------------------------------------------- /pb/go/trpc/v2/go.sum: -------------------------------------------------------------------------------- 1 | github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= 2 | github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= 3 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 4 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= 5 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 6 | google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= 7 | google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= 8 | google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= 9 | -------------------------------------------------------------------------------- /pb/go/trpc/v2/proto/trpc_options.pb.go: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making tRPC available. 2 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved. 3 | // If you have downloaded a copy of the tRPC source code from Tencent, 4 | // please note that tRPC source code is licensed under the Apache 2.0 License, 5 | // A copy of the Apache 2.0 License is included in this file. 6 | 7 | // Code generated by protoc-gen-go. DO NOT EDIT. 8 | // versions: 9 | // protoc-gen-go v1.28.1 10 | // protoc v5.27.1 11 | // source: trpc/v2/proto/trpc_options.proto 12 | 13 | package proto 14 | 15 | import ( 16 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 17 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 18 | descriptorpb "google.golang.org/protobuf/types/descriptorpb" 19 | reflect "reflect" 20 | ) 21 | 22 | const ( 23 | // Verify that this generated code is sufficiently up-to-date. 24 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 25 | // Verify that runtime/protoimpl is sufficiently up-to-date. 26 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 27 | ) 28 | 29 | var file_trpc_v2_proto_trpc_options_proto_extTypes = []protoimpl.ExtensionInfo{ 30 | { 31 | ExtendedType: (*descriptorpb.MethodOptions)(nil), 32 | ExtensionType: (*string)(nil), 33 | Field: 1155, 34 | Name: "trpc.v2.alias", 35 | Tag: "bytes,1155,opt,name=alias", 36 | Filename: "trpc/v2/proto/trpc_options.proto", 37 | }, 38 | { 39 | ExtendedType: (*descriptorpb.FieldOptions)(nil), 40 | ExtensionType: (*string)(nil), 41 | Field: 1156, 42 | Name: "trpc.v2.go_tag", 43 | Tag: "bytes,1156,opt,name=go_tag", 44 | Filename: "trpc/v2/proto/trpc_options.proto", 45 | }, 46 | } 47 | 48 | // Extension fields to descriptorpb.MethodOptions. 49 | var ( 50 | // optional string alias = 1155; 51 | E_Alias = &file_trpc_v2_proto_trpc_options_proto_extTypes[0] 52 | ) 53 | 54 | // Extension fields to descriptorpb.FieldOptions. 55 | var ( 56 | // optional string go_tag = 1156; 57 | E_GoTag = &file_trpc_v2_proto_trpc_options_proto_extTypes[1] 58 | ) 59 | 60 | var File_trpc_v2_proto_trpc_options_proto protoreflect.FileDescriptor 61 | 62 | var file_trpc_v2_proto_trpc_options_proto_rawDesc = []byte{ 63 | 0x0a, 0x20, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x32, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 64 | 0x74, 0x72, 0x70, 0x63, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 65 | 0x74, 0x6f, 0x12, 0x07, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x32, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 66 | 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 67 | 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3a, 0x35, 0x0a, 68 | 0x05, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 69 | 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 70 | 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x83, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 71 | 0x6c, 0x69, 0x61, 0x73, 0x3a, 0x35, 0x0a, 0x06, 0x67, 0x6f, 0x5f, 0x74, 0x61, 0x67, 0x12, 0x1d, 72 | 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 73 | 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x84, 0x09, 74 | 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x67, 0x6f, 0x54, 0x61, 0x67, 0x42, 0x52, 0x0a, 0x1d, 0x63, 75 | 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x2e, 0x74, 0x72, 0x70, 0x63, 0x2e, 76 | 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x65, 0x78, 0x74, 0x5a, 0x31, 0x74, 0x72, 77 | 0x70, 0x63, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2f, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x74, 0x72, 78 | 0x70, 0x63, 0x2d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x70, 0x62, 0x2f, 0x67, 79 | 0x6f, 0x2f, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x32, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 80 | 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 81 | } 82 | 83 | var file_trpc_v2_proto_trpc_options_proto_goTypes = []interface{}{ 84 | (*descriptorpb.MethodOptions)(nil), // 0: google.protobuf.MethodOptions 85 | (*descriptorpb.FieldOptions)(nil), // 1: google.protobuf.FieldOptions 86 | } 87 | var file_trpc_v2_proto_trpc_options_proto_depIdxs = []int32{ 88 | 0, // 0: trpc.v2.alias:extendee -> google.protobuf.MethodOptions 89 | 1, // 1: trpc.v2.go_tag:extendee -> google.protobuf.FieldOptions 90 | 2, // [2:2] is the sub-list for method output_type 91 | 2, // [2:2] is the sub-list for method input_type 92 | 2, // [2:2] is the sub-list for extension type_name 93 | 0, // [0:2] is the sub-list for extension extendee 94 | 0, // [0:0] is the sub-list for field type_name 95 | } 96 | 97 | func init() { file_trpc_v2_proto_trpc_options_proto_init() } 98 | func file_trpc_v2_proto_trpc_options_proto_init() { 99 | if File_trpc_v2_proto_trpc_options_proto != nil { 100 | return 101 | } 102 | type x struct{} 103 | out := protoimpl.TypeBuilder{ 104 | File: protoimpl.DescBuilder{ 105 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 106 | RawDescriptor: file_trpc_v2_proto_trpc_options_proto_rawDesc, 107 | NumEnums: 0, 108 | NumMessages: 0, 109 | NumExtensions: 2, 110 | NumServices: 0, 111 | }, 112 | GoTypes: file_trpc_v2_proto_trpc_options_proto_goTypes, 113 | DependencyIndexes: file_trpc_v2_proto_trpc_options_proto_depIdxs, 114 | ExtensionInfos: file_trpc_v2_proto_trpc_options_proto_extTypes, 115 | }.Build() 116 | File_trpc_v2_proto_trpc_options_proto = out.File 117 | file_trpc_v2_proto_trpc_options_proto_rawDesc = nil 118 | file_trpc_v2_proto_trpc_options_proto_goTypes = nil 119 | file_trpc_v2_proto_trpc_options_proto_depIdxs = nil 120 | } 121 | -------------------------------------------------------------------------------- /pb/go/trpc/v2/swagger/swagger.pb.go: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making tRPC available. 2 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved. 3 | // If you have downloaded a copy of the tRPC source code from Tencent, 4 | // please note that tRPC source code is licensed under the Apache 2.0 License, 5 | // A copy of the Apache 2.0 License is included in this file. 6 | 7 | // Code generated by protoc-gen-go. DO NOT EDIT. 8 | // versions: 9 | // protoc-gen-go v1.28.1 10 | // protoc v5.27.1 11 | // source: trpc/v2/swagger/swagger.proto 12 | 13 | package swagger 14 | 15 | import ( 16 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 17 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 18 | descriptorpb "google.golang.org/protobuf/types/descriptorpb" 19 | reflect "reflect" 20 | sync "sync" 21 | ) 22 | 23 | const ( 24 | // Verify that this generated code is sufficiently up-to-date. 25 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 26 | // Verify that runtime/protoimpl is sufficiently up-to-date. 27 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 28 | ) 29 | 30 | // to gen swagger json 31 | type SwaggerRule struct { 32 | state protoimpl.MessageState 33 | sizeCache protoimpl.SizeCache 34 | unknownFields protoimpl.UnknownFields 35 | 36 | Title string `protobuf:"bytes,50103,opt,name=title,proto3" json:"title,omitempty"` 37 | Method string `protobuf:"bytes,50104,opt,name=method,proto3" json:"method,omitempty"` 38 | Description string `protobuf:"bytes,50105,opt,name=description,proto3" json:"description,omitempty"` 39 | Params []*SwaggerParam `protobuf:"bytes,50106,rep,name=params,proto3" json:"params,omitempty"` 40 | } 41 | 42 | func (x *SwaggerRule) Reset() { 43 | *x = SwaggerRule{} 44 | if protoimpl.UnsafeEnabled { 45 | mi := &file_trpc_v2_swagger_swagger_proto_msgTypes[0] 46 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 47 | ms.StoreMessageInfo(mi) 48 | } 49 | } 50 | 51 | func (x *SwaggerRule) String() string { 52 | return protoimpl.X.MessageStringOf(x) 53 | } 54 | 55 | func (*SwaggerRule) ProtoMessage() {} 56 | 57 | func (x *SwaggerRule) ProtoReflect() protoreflect.Message { 58 | mi := &file_trpc_v2_swagger_swagger_proto_msgTypes[0] 59 | if protoimpl.UnsafeEnabled && x != nil { 60 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 61 | if ms.LoadMessageInfo() == nil { 62 | ms.StoreMessageInfo(mi) 63 | } 64 | return ms 65 | } 66 | return mi.MessageOf(x) 67 | } 68 | 69 | // Deprecated: Use SwaggerRule.ProtoReflect.Descriptor instead. 70 | func (*SwaggerRule) Descriptor() ([]byte, []int) { 71 | return file_trpc_v2_swagger_swagger_proto_rawDescGZIP(), []int{0} 72 | } 73 | 74 | func (x *SwaggerRule) GetTitle() string { 75 | if x != nil { 76 | return x.Title 77 | } 78 | return "" 79 | } 80 | 81 | func (x *SwaggerRule) GetMethod() string { 82 | if x != nil { 83 | return x.Method 84 | } 85 | return "" 86 | } 87 | 88 | func (x *SwaggerRule) GetDescription() string { 89 | if x != nil { 90 | return x.Description 91 | } 92 | return "" 93 | } 94 | 95 | func (x *SwaggerRule) GetParams() []*SwaggerParam { 96 | if x != nil { 97 | return x.Params 98 | } 99 | return nil 100 | } 101 | 102 | type SwaggerParam struct { 103 | state protoimpl.MessageState 104 | sizeCache protoimpl.SizeCache 105 | unknownFields protoimpl.UnknownFields 106 | 107 | Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` 108 | Required bool `protobuf:"varint,2,opt,name=required,proto3" json:"required,omitempty"` 109 | Default string `protobuf:"bytes,3,opt,name=default,proto3" json:"default,omitempty"` 110 | } 111 | 112 | func (x *SwaggerParam) Reset() { 113 | *x = SwaggerParam{} 114 | if protoimpl.UnsafeEnabled { 115 | mi := &file_trpc_v2_swagger_swagger_proto_msgTypes[1] 116 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 117 | ms.StoreMessageInfo(mi) 118 | } 119 | } 120 | 121 | func (x *SwaggerParam) String() string { 122 | return protoimpl.X.MessageStringOf(x) 123 | } 124 | 125 | func (*SwaggerParam) ProtoMessage() {} 126 | 127 | func (x *SwaggerParam) ProtoReflect() protoreflect.Message { 128 | mi := &file_trpc_v2_swagger_swagger_proto_msgTypes[1] 129 | if protoimpl.UnsafeEnabled && x != nil { 130 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 131 | if ms.LoadMessageInfo() == nil { 132 | ms.StoreMessageInfo(mi) 133 | } 134 | return ms 135 | } 136 | return mi.MessageOf(x) 137 | } 138 | 139 | // Deprecated: Use SwaggerParam.ProtoReflect.Descriptor instead. 140 | func (*SwaggerParam) Descriptor() ([]byte, []int) { 141 | return file_trpc_v2_swagger_swagger_proto_rawDescGZIP(), []int{1} 142 | } 143 | 144 | func (x *SwaggerParam) GetName() string { 145 | if x != nil { 146 | return x.Name 147 | } 148 | return "" 149 | } 150 | 151 | func (x *SwaggerParam) GetRequired() bool { 152 | if x != nil { 153 | return x.Required 154 | } 155 | return false 156 | } 157 | 158 | func (x *SwaggerParam) GetDefault() string { 159 | if x != nil { 160 | return x.Default 161 | } 162 | return "" 163 | } 164 | 165 | var file_trpc_v2_swagger_swagger_proto_extTypes = []protoimpl.ExtensionInfo{ 166 | { 167 | ExtendedType: (*descriptorpb.MethodOptions)(nil), 168 | ExtensionType: (*SwaggerRule)(nil), 169 | Field: 1156, 170 | Name: "trpc.v2.swagger", 171 | Tag: "bytes,1156,opt,name=swagger", 172 | Filename: "trpc/v2/swagger/swagger.proto", 173 | }, 174 | } 175 | 176 | // Extension fields to descriptorpb.MethodOptions. 177 | var ( 178 | // optional trpc.v2.SwaggerRule swagger = 1156; 179 | E_Swagger = &file_trpc_v2_swagger_swagger_proto_extTypes[0] 180 | ) 181 | 182 | var File_trpc_v2_swagger_swagger_proto protoreflect.FileDescriptor 183 | 184 | var file_trpc_v2_swagger_swagger_proto_rawDesc = []byte{ 185 | 0x0a, 0x1d, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x32, 0x2f, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 186 | 0x72, 0x2f, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 187 | 0x07, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x32, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 188 | 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 189 | 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x94, 0x01, 0x0a, 0x0b, 0x53, 190 | 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x05, 0x74, 0x69, 191 | 0x74, 0x6c, 0x65, 0x18, 0xb7, 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 192 | 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0xb8, 0x87, 0x03, 193 | 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x22, 0x0a, 0x0b, 194 | 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xb9, 0x87, 0x03, 0x20, 195 | 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 196 | 0x12, 0x2f, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0xba, 0x87, 0x03, 0x20, 0x03, 197 | 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x77, 0x61, 198 | 0x67, 0x67, 0x65, 0x72, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 199 | 0x73, 0x22, 0x58, 0x0a, 0x0c, 0x53, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x50, 0x61, 0x72, 0x61, 200 | 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 201 | 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 202 | 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 203 | 0x64, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x18, 0x03, 0x20, 0x01, 204 | 0x28, 0x09, 0x52, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x3a, 0x4f, 0x0a, 0x07, 0x73, 205 | 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 206 | 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 207 | 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x84, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 208 | 0x74, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x52, 209 | 0x75, 0x6c, 0x65, 0x52, 0x07, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x42, 0x54, 0x0a, 0x1d, 210 | 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x2e, 0x74, 0x72, 0x70, 0x63, 211 | 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x65, 0x78, 0x74, 0x5a, 0x33, 0x74, 212 | 0x72, 0x70, 0x63, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2f, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x74, 213 | 0x72, 0x70, 0x63, 0x2d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x70, 0x62, 0x2f, 214 | 0x67, 0x6f, 0x2f, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x32, 0x2f, 0x73, 0x77, 0x61, 0x67, 0x67, 215 | 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 216 | } 217 | 218 | var ( 219 | file_trpc_v2_swagger_swagger_proto_rawDescOnce sync.Once 220 | file_trpc_v2_swagger_swagger_proto_rawDescData = file_trpc_v2_swagger_swagger_proto_rawDesc 221 | ) 222 | 223 | func file_trpc_v2_swagger_swagger_proto_rawDescGZIP() []byte { 224 | file_trpc_v2_swagger_swagger_proto_rawDescOnce.Do(func() { 225 | file_trpc_v2_swagger_swagger_proto_rawDescData = protoimpl.X.CompressGZIP(file_trpc_v2_swagger_swagger_proto_rawDescData) 226 | }) 227 | return file_trpc_v2_swagger_swagger_proto_rawDescData 228 | } 229 | 230 | var file_trpc_v2_swagger_swagger_proto_msgTypes = make([]protoimpl.MessageInfo, 2) 231 | var file_trpc_v2_swagger_swagger_proto_goTypes = []interface{}{ 232 | (*SwaggerRule)(nil), // 0: trpc.v2.SwaggerRule 233 | (*SwaggerParam)(nil), // 1: trpc.v2.SwaggerParam 234 | (*descriptorpb.MethodOptions)(nil), // 2: google.protobuf.MethodOptions 235 | } 236 | var file_trpc_v2_swagger_swagger_proto_depIdxs = []int32{ 237 | 1, // 0: trpc.v2.SwaggerRule.params:type_name -> trpc.v2.SwaggerParam 238 | 2, // 1: trpc.v2.swagger:extendee -> google.protobuf.MethodOptions 239 | 0, // 2: trpc.v2.swagger:type_name -> trpc.v2.SwaggerRule 240 | 3, // [3:3] is the sub-list for method output_type 241 | 3, // [3:3] is the sub-list for method input_type 242 | 2, // [2:3] is the sub-list for extension type_name 243 | 1, // [1:2] is the sub-list for extension extendee 244 | 0, // [0:1] is the sub-list for field type_name 245 | } 246 | 247 | func init() { file_trpc_v2_swagger_swagger_proto_init() } 248 | func file_trpc_v2_swagger_swagger_proto_init() { 249 | if File_trpc_v2_swagger_swagger_proto != nil { 250 | return 251 | } 252 | if !protoimpl.UnsafeEnabled { 253 | file_trpc_v2_swagger_swagger_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { 254 | switch v := v.(*SwaggerRule); i { 255 | case 0: 256 | return &v.state 257 | case 1: 258 | return &v.sizeCache 259 | case 2: 260 | return &v.unknownFields 261 | default: 262 | return nil 263 | } 264 | } 265 | file_trpc_v2_swagger_swagger_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { 266 | switch v := v.(*SwaggerParam); i { 267 | case 0: 268 | return &v.state 269 | case 1: 270 | return &v.sizeCache 271 | case 2: 272 | return &v.unknownFields 273 | default: 274 | return nil 275 | } 276 | } 277 | } 278 | type x struct{} 279 | out := protoimpl.TypeBuilder{ 280 | File: protoimpl.DescBuilder{ 281 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 282 | RawDescriptor: file_trpc_v2_swagger_swagger_proto_rawDesc, 283 | NumEnums: 0, 284 | NumMessages: 2, 285 | NumExtensions: 1, 286 | NumServices: 0, 287 | }, 288 | GoTypes: file_trpc_v2_swagger_swagger_proto_goTypes, 289 | DependencyIndexes: file_trpc_v2_swagger_swagger_proto_depIdxs, 290 | MessageInfos: file_trpc_v2_swagger_swagger_proto_msgTypes, 291 | ExtensionInfos: file_trpc_v2_swagger_swagger_proto_extTypes, 292 | }.Build() 293 | File_trpc_v2_swagger_swagger_proto = out.File 294 | file_trpc_v2_swagger_swagger_proto_rawDesc = nil 295 | file_trpc_v2_swagger_swagger_proto_goTypes = nil 296 | file_trpc_v2_swagger_swagger_proto_depIdxs = nil 297 | } 298 | -------------------------------------------------------------------------------- /proposal/README.md: -------------------------------------------------------------------------------- 1 | English | [中文](README_zh_CN.md) 2 | 3 | # tRPC RFCs 4 | 5 | ## Introduction 6 | 7 | Before getting started, please familiarize yourself with the tRPC project through the [official website](https://trpc.group/). 8 | 9 | This repository is mainly used to record proposals for major feature evolutions in tRPC. 10 | It can: 11 | 12 | - Provide upcoming major feature updates and future plans for tRPC. 13 | - Record oversize features that are not suitable for issues. 14 | - Standardize the development process for large features. 15 | - Encourage open discussions based on design documents. 16 | 17 | ## Proposal Types 18 | 19 | - `An` General features that affect all languages. 20 | - `Ln` Language-specific changes. 21 | - `Gn` Protocol layer changes. 22 | - `Pn` Changes to this process itself. 23 | 24 | Use 4 labels to record the maximum tRPC number. 25 | When assigning a number to a new proposal, take the corresponding label number, and then increment the label number by one. 26 | 27 | ## Process 28 | 29 | 1. Create an issue to determine the tRPC number for the feature. 30 | 2. Clone the repo, copy the TEMPLATE.md, and rename it to $Type-$Summary. 31 | For proposals specific to a programming language, insert the language name in the name as $Type-$Language-$Summary. 32 | 3. Submit an MR. The title of the MR should include the tRPC number. 33 | 4. After the OWNER completes the first draft of the proposal, the review process can be initiated. 34 | 5. Invite as many people as possible for the review, collect feedback, and update the proposal. 35 | Choose the appropriate discussion method: 36 | If the proposal has a wide impact (e.g., An type proposals), initiate a discussion in the corresponding issue and update the discussion link in the proposal. 37 | If the proposal is related to implementation details (e.g., `Ln` type proposals), discussion can be limited to the MR. 38 | 6. Once the proposal is approved, merge the MR. 39 | To ensure a clean history, merging must be done using the rebase + squash method. 40 | Commit messages must start with the tRPC number. 41 | 7. Updates to accepted proposals should indicate the tRPC number in the MR. 42 | Depending on the extent of the changes, decide whether a new discussion is needed. -------------------------------------------------------------------------------- /proposal/README.zh_CN.md: -------------------------------------------------------------------------------- 1 | [English](README.md) | 中文 2 | 3 | # tRPC RFCs 4 | 5 | ## 介绍 6 | 7 | 在开始之前,请先通过[官方网站](https://trpc.group/)了解 tRPC 项目。 8 | 9 | 本仓库主要用于记录 tRPC 中重大功能演进的提案。它可以 10 | 11 | * 提供 tRPC 即将发生的大功能更新以及未来的规划。 12 | * 记录过大的不适用于 issue 的功能。 13 | * 规范大型功能的开发流程。 14 | * 鼓励基于设计文档的开放式讨论。 15 | 16 | ## 提案类型 17 | 18 | * `#An` 影响所有语言的通用功能。 19 | * `#Ln` 各个语言相关的改动。 20 | * `#Gn` 协议层的改动。 21 | * `#Pn` 该流程本身的改动。 22 | 23 | 使用 4 个 label 来记录最大 tRPC 编号。为新提案分配编号时,取对应 label 编号,然后将 label 编号加一。 24 | 25 | ## 流程 26 | 27 | 1. 提 issue,确定功能的 tRPC 编号。 28 | 2. 克隆 repo,拷贝模板 `TEMPLATE.md`,并将它重命名为 `$Type-$Summary`, 29 | * 对于特定编程语言的提案,需要在在名字中插入语言名 `$Type-$Language-$Summary`。 30 | 3. 提交 MR。MR 的标题中需要带上 tRPC 编号。 31 | 4. OWNER 完成初版提案后,可以开启 review。 32 | 5. review 需要邀请尽可能多的人,收集反馈,更新提案。选择合适的讨论方式: 33 | * 如果提案影响广泛(比如,`An` 类提案),需要在对应的 issue 中开启话题进行讨论,并将讨论链接更新到提案中。 34 | * 如果提案与实现细节相关(比如,Ln 类提案),可以只在 MR 中讨论。 35 | 6. 提案通过后,合并 MR。 36 | * 为了保证干净的历史,必须使用 rebase + squash 的方式进行合并。 37 | * commit 信息必须以 tRPC 编号开始。 38 | 7. 对已经接受的提案的更新需要在 MR 中注明 tRPC 编号。根据修改程度,决定是否需要开启新的讨论。 39 | -------------------------------------------------------------------------------- /proposal/TEMPLATE.md: -------------------------------------------------------------------------------- 1 | English | [中文](TEMPLATE_zh_CN.md) 2 | 3 | # Title 4 | 5 | - Author: (Author name, collaborators name) 6 | - Reviewers: 7 | - Status: (Draft, Under Review, Ready for Implementation, Implemented) 8 | - Implemented Languages: (Omit for `Ln` type proposals) 9 | - Last Updated: 10 | - Discussion Link: 11 | 12 | ## Table of Contents 13 | 14 | - [Summary](#summary) 15 | - [Background](#background) 16 | - [Related Proposals](#related-proposals) 17 | - [Design Details](#design-details) 18 | - [Implementation Details](#implementation-details) 19 | - [Industry Implementations](#industry-implementations) 20 | - [Other Issues](#other-issues) 21 | 22 | ## Summary 23 | 24 | xxx 25 | 26 | ## Background 27 | 28 | Relevant background knowledge and the problems the proposal aims to solve. 29 | 30 | ## Related Proposals 31 | 32 | ### Other related proposals 33 | 34 | ## Design Details 35 | 36 | The detailed design part. 37 | If this proposal is a specific language version of an `An` proposal, provide a link to the parent proposal. 38 | 39 | ## Implementation Details 40 | 41 | This section can be omitted if it is an `An` type proposal. 42 | 43 | ## Industry Implementations 44 | 45 | For `Ln` type proposals, this section can be provided optionally. 46 | 47 | ## Other Issues 48 | 49 | Some debatable issues that the author is uncertain about. 50 | This section can be omitted. -------------------------------------------------------------------------------- /proposal/TEMPLATE.zh_CN.md: -------------------------------------------------------------------------------- 1 | [English](TEMPLATE.md) | 中文 2 | 3 | # 标题 4 | 5 | * 作者:(作者名字,合作者名字) 6 | * 批准者: 7 | * 状态:(草案,评审中,准备实现,已经实现) 8 | * 已实现的语言:(`Ln` 类型提案省略) 9 | * 上次更新时间: 10 | * 讨论链接: 11 | 12 | ## 目录 13 | 14 | * [概要](#概要) 15 | * [背景](#背景) 16 | * [相关提案](#相关提案) 17 | * [设计细节](#设计细节) 18 | * [实现细节](#实现细节) 19 | * [业界实现](#业界实现) 20 | * [其他问题](#其他问题) 21 | 22 | ## 概要 23 | 24 | xxx 25 | 26 | ## 背景 27 | 28 | 相关背景知识及提案要解决的问题 29 | 30 | ### 相关提案 31 | 32 | * 其他相关提案 33 | 34 | ## 设计细节 35 | 36 | 设计的细节部分。如果该提案是某个 `An` 提案的特定语言版,则提供父提案的链接即可。 37 | 38 | ## 实现细节 39 | 40 | 如果这是一个 `An` 类型的提案,本节可以省略。 41 | 42 | ## 业界实现 43 | 44 | 对于 `Ln` 类型提案,可以选择性地提供本节。 45 | 46 | ## 其他问题 47 | 48 | 作者不确定的一些值得商榷的问题。本节可省略。 -------------------------------------------------------------------------------- /test/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trpc-group/trpc/398abb395da5ac2a7da1806e9253f488737a18e2/test/BUILD -------------------------------------------------------------------------------- /test/README.md: -------------------------------------------------------------------------------- 1 | tRPC各语言能正常生成可编译通过代码的测试 2 | 3 | - cpp:c++语言能正常生成桩代码 4 | -------------------------------------------------------------------------------- /test/cpp/BUILD: -------------------------------------------------------------------------------- 1 | cc_proto_library( 2 | name = "cc_trpc_proto", 3 | deps = [ 4 | "//trpc:trpc_proto", 5 | ], 6 | ) 7 | 8 | cc_proto_library( 9 | name = "cc_trpc_options_proto", 10 | deps = [ 11 | "//trpc/proto:trpc_options_proto", 12 | ], 13 | ) 14 | 15 | cc_proto_library( 16 | name = "cc_annotations_proto", 17 | deps = [ 18 | "//trpc/api:annotations_proto", 19 | ], 20 | ) 21 | 22 | cc_proto_library( 23 | name = "cc_http_proto", 24 | deps = [ 25 | "//trpc/api:http_proto", 26 | ], 27 | ) 28 | 29 | cc_proto_library( 30 | name = "cc_swagger_proto", 31 | deps = [ 32 | "//trpc/swagger:swagger_proto", 33 | ], 34 | ) 35 | 36 | cc_proto_library( 37 | name = "cc_validate_proto", 38 | deps = [ 39 | "//trpc/validate:validate_proto", 40 | ], 41 | ) 42 | -------------------------------------------------------------------------------- /testbuild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | bazel build ... -------------------------------------------------------------------------------- /tool/wireshark_trpc.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- 3 | -- Tencent is pleased to support the open source community by making tRPC available. 4 | -- 5 | -- Copyright (C) 2024 THL A29 Limited, a Tencent company. 6 | -- All rights reserved. 7 | -- 8 | -- If you have downloaded a copy of the tRPC source code from Tencent, 9 | -- please note that tRPC source code is licensed under the Apache 2.0 License, 10 | -- A copy of the Apache 2.0 License is included in this file. 11 | -- 12 | -- 13 | -- tRPC is licensed under the Apache 2.0 License, and includes source codes from 14 | -- the following components: 15 | -- 1. incubator-brpc 16 | -- Copyright (C) 2019 The Apache Software Foundation 17 | -- incubator-brpc is licensed under the Apache 2.0 License. 18 | -- 19 | -- 20 | 21 | local protocol_name = "trpc" 22 | local trpc_proto = Proto(protocol_name, "tRPC Protocol Dissector") 23 | 24 | local field_magic = ProtoField.uint16(protocol_name .. ".magic", "Magic", base.HEX) 25 | local field_type = ProtoField.uint8(protocol_name .. ".type", "Packet Type", base.DEC) 26 | local field_stream = ProtoField.uint8(protocol_name .. ".stream", "Stream Type", base.DEC) 27 | local field_total_size = ProtoField.uint32(protocol_name .. ".total_size", "Total Size", base.DEC) 28 | local field_header_size= ProtoField.uint16(protocol_name .. ".header_size", "Header Size", base.DEC) 29 | local field_unique_id = ProtoField.uint32(protocol_name .. ".unique_id", "Unique ID", base.DEC) 30 | local field_version = ProtoField.uint8(protocol_name .. ".version", "Version", base.DEC) 31 | local field_reserved = ProtoField.uint8(protocol_name .. ".reserved", "Reserved", base.DEC) 32 | trpc_proto.fields = {field_magic, field_type, field_stream, field_total_size, field_header_size, field_unique_id, field_version, field_reserved} 33 | 34 | local MAGIC_CODE_TRPC = "0930" 35 | local PROTO_HEADER_LENGTH = 16 36 | 37 | local tcp_src_port = Field.new("tcp.srcport") 38 | local tcp_dst_port = Field.new("tcp.dstport") 39 | local tcp_stream = Field.new("tcp.stream") 40 | 41 | local proto_f_protobuf_field_name = Field.new("protobuf.field.name") 42 | local proto_f_protobuf_field_value = Field.new("protobuf.field.value") 43 | 44 | local data_dissector = Dissector.get("data") 45 | local protobuf_dissector = Dissector.get("protobuf") 46 | 47 | ---------------------------------------- 48 | -- declare functions 49 | local check_length = function() end 50 | local dissect_proto = function() end 51 | 52 | ---------------------------------------- 53 | -- main dissector 54 | function trpc_proto.dissector(tvbuf, pktinfo, root) 55 | local pktlen = tvbuf:len() 56 | 57 | local bytes_consumed = 0 58 | 59 | while bytes_consumed < pktlen do 60 | local result = dissect_proto(tvbuf, pktinfo, root, bytes_consumed) 61 | 62 | if result > 0 then 63 | bytes_consumed = bytes_consumed + result 64 | elseif result == 0 then 65 | -- hit an error 66 | return 0 67 | else 68 | pktinfo.desegment_offset = bytes_consumed 69 | -- require more bytes 70 | pktinfo.desegment_len = -result 71 | 72 | return pktlen 73 | end 74 | end 75 | 76 | return bytes_consumed 77 | end 78 | 79 | -------------------------------------------------------------------------------- 80 | -- heuristic 81 | -- tcp_stream_id <-> {client_port, server_port, {request_id<->method_name}} 82 | local stream_map = {} 83 | local function heur_dissect_proto(tvbuf, pktinfo, root) 84 | -- dynmaic decide client or server data 85 | -- by first tcp syn frame 86 | local f_src_port = tcp_src_port()() 87 | local f_dst_port = tcp_dst_port()() 88 | local stream_n = tcp_stream().value 89 | if stream_map[stream_n] == nil then 90 | stream_map[stream_n] = {f_src_port, f_dst_port, {}} 91 | end 92 | 93 | if (tvbuf:len() < PROTO_HEADER_LENGTH) then 94 | return false 95 | end 96 | 97 | local magic = tvbuf:range(0, 2):bytes():tohex() 98 | -- for range dissectors 99 | if magic ~= MAGIC_CODE_TRPC then 100 | return false 101 | end 102 | 103 | trpc_proto.dissector(tvbuf, pktinfo, root) 104 | 105 | pktinfo.conversation = trpc_proto 106 | 107 | return true 108 | end 109 | 110 | trpc_proto:register_heuristic("tcp", heur_dissect_proto) 111 | 112 | -------------------------------------------------------------------------------- 113 | 114 | -- check packet length, return length of packet if valid 115 | check_length = function(tvbuf, offset) 116 | local msglen = tvbuf:len() - offset 117 | 118 | if msglen ~= tvbuf:reported_length_remaining(offset) then 119 | -- captured packets are being sliced/cut-off, so don't try to desegment/reassemble 120 | LM_WARN("Captured packet was shorter than original, can't reassemble") 121 | return 0 122 | end 123 | 124 | if msglen < PROTO_HEADER_LENGTH then 125 | -- we need more bytes, so tell the main dissector function that we 126 | -- didn't dissect anything, and we need an unknown number of more 127 | -- bytes (which is what "DESEGMENT_ONE_MORE_SEGMENT" is used for) 128 | return -DESEGMENT_ONE_MORE_SEGMENT 129 | end 130 | 131 | -- if we got here, then we know we have enough bytes in the Tvb buffer 132 | -- to at least figure out whether this is valid trpc packet 133 | 134 | local magic = tvbuf:range(offset, 2):bytes():tohex() 135 | if magic ~= MAGIC_CODE_TRPC then 136 | return 0 137 | end 138 | 139 | local packet_size = tvbuf:range(offset+4, 4):uint() 140 | if msglen < packet_size then 141 | -- Need more bytes to desegment full trpc packet 142 | return -(packet_size - msglen) 143 | end 144 | 145 | return packet_size 146 | end 147 | 148 | -------------------------------------------------------------------------------- 149 | 150 | dissect_proto = function(tvbuf, pktinfo, root, offset) 151 | local len = check_length(tvbuf, offset) 152 | if len <= 0 then 153 | return len 154 | end 155 | 156 | -- update 'Protocol' field 157 | if offset == 0 then 158 | pktinfo.cols.protocol:set("tRPC") 159 | end 160 | 161 | local f_src_port = tcp_src_port()() 162 | local f_dst_port = tcp_dst_port()() 163 | 164 | local direction 165 | local stream_n = tcp_stream().value 166 | if f_src_port == stream_map[stream_n][1] then 167 | pktinfo.private["pb_msg_type"] = "message,trpc.RequestProtocol" 168 | direction = "request" 169 | end 170 | if f_src_port == stream_map[stream_n][2] then 171 | pktinfo.private["pb_msg_type"] = "message,trpc.ResponseProtocol" 172 | direction = "response" 173 | end 174 | 175 | -- check packet length, 176 | local magic_value = tvbuf(offset, 2) 177 | local type_value = tvbuf(offset+2, 1) 178 | local stream_value = tvbuf(offset+3, 1) 179 | local total_size_value = tvbuf(offset+4, 4) 180 | local header_size_value = tvbuf(offset+8, 2) 181 | local unique_id_value = tvbuf(offset+10, 4) 182 | local version_value = tvbuf(offset+14, 1) 183 | local reserved_value = tvbuf(offset+15, 1) 184 | 185 | local header_length = header_size_value:uint() 186 | local total_length = total_size_value:uint() 187 | local tree = root:add(trpc_proto, tvbuf:range(offset, len), "tRPC Protocol Data") 188 | 189 | data_dissector:call(tvbuf, pktinfo, tree) 190 | 191 | local t = tree:add(trpc_proto, tvbuf) 192 | t:add(field_magic, magic_value) 193 | t:add(field_type, type_value) 194 | t:add(field_stream, stream_value) 195 | t:add(field_total_size, total_size_value) 196 | t:add(field_header_size, header_size_value) 197 | t:add(field_unique_id, unique_id_value) 198 | t:add(field_version, version_value) 199 | t:add(field_reserved, reserved_value) 200 | 201 | -- solve the problem of parsing errors when multiple RPCs are included in a packet 202 | local protobuf_field_names = { proto_f_protobuf_field_name() } 203 | local pre_field_nums = #protobuf_field_names 204 | pcall(Dissector.call, protobuf_dissector, tvbuf(offset+16, header_length):tvb(), pktinfo, tree) 205 | 206 | -- Add bussiness rpc pb 207 | -- Get invoke rpc method name from trpc.RequestProtocol 208 | protobuf_field_names = { proto_f_protobuf_field_name() } 209 | local cur_field_nums = #protobuf_field_names 210 | local protobuf_field_values = { proto_f_protobuf_field_value() } 211 | local method 212 | -- default request id 213 | local request_id = 0 214 | for k = pre_field_nums + 1, cur_field_nums do 215 | local v = protobuf_field_names[k] 216 | if v.value == "func" then 217 | method = protobuf_field_values[k].range:string(ENC_UTF8) 218 | elseif v.value == "request_id" then 219 | request_id = protobuf_field_values[k].range:uint() 220 | end 221 | end 222 | 223 | local tvb_body = tvbuf:range(offset + 16 + header_length, total_length - header_length - 16):tvb() 224 | if method ~= nil then 225 | -- only req contains method, correlate it with request id so that response protocol can use. 226 | stream_map[stream_n][3][request_id] = method 227 | pktinfo.private["pb_msg_type"] = "application/trpc," .. method .. "," .. direction 228 | else 229 | -- get method for the same request id 230 | method = stream_map[stream_n][3][request_id] 231 | pktinfo.private["pb_msg_type"] = "application/trpc," .. method .. "," .. direction 232 | end 233 | pcall(Dissector.call, protobuf_dissector, tvb_body, pktinfo, tree) 234 | 235 | return total_length 236 | end -------------------------------------------------------------------------------- /trpc/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | proto_library( 4 | name = "trpc_proto", 5 | srcs = [ 6 | "trpc.proto", 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /trpc/api/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | proto_library( 4 | name = "annotations_proto", 5 | srcs = [ 6 | "annotations.proto", 7 | ], 8 | deps = [ 9 | "//trpc/api:http_proto", 10 | "@com_google_protobuf//:descriptor_proto", 11 | ], 12 | ) 13 | 14 | proto_library( 15 | name = "http_proto", 16 | srcs = [ 17 | "http.proto", 18 | "openapiv2.proto", 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /trpc/api/annotations.proto: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making tRPC available. 2 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved. 3 | // If you have downloaded a copy of the tRPC source code from Tencent, 4 | // please note that tRPC source code is licensed under the Apache 2.0 License, 5 | // A copy of the Apache 2.0 License is included in this file. 6 | 7 | // Copyright 2015 Google LLC 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | // 21 | // This file may have been modified by THL A29 Limited ("Tencent Modifications"). 22 | // All Tencent Modifications are Copyright (C) 2023 THL A29 Limited. 23 | 24 | syntax = "proto3"; 25 | 26 | package trpc.api; 27 | 28 | import "trpc/api/http.proto"; 29 | import "trpc/api/openapiv2.proto"; 30 | import "google/protobuf/descriptor.proto"; 31 | 32 | option go_package = "trpc.group/trpc/trpc-protocol/pb/go/trpc/api"; 33 | option java_package = "com.tencent.trpc.protobuf.ext"; 34 | 35 | extend google.protobuf.MethodOptions { 36 | HttpRule http = 50201; 37 | } 38 | 39 | extend google.protobuf.MessageOptions { 40 | Schema openapiv2_schema = 50201; 41 | } 42 | -------------------------------------------------------------------------------- /trpc/api/http.proto: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making tRPC available. 2 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved. 3 | // If you have downloaded a copy of the tRPC source code from Tencent, 4 | // please note that tRPC source code is licensed under the Apache 2.0 License, 5 | // A copy of the Apache 2.0 License is included in this file. 6 | 7 | // Copyright 2023 Google LLC 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | // 21 | // This file may have been modified by THL A29 Limited ("Tencent Modifications"). 22 | // All Tencent Modifications are Copyright (C) 2023 THL A29 Limited. 23 | 24 | syntax = "proto3"; 25 | 26 | package trpc.api; 27 | 28 | option go_package = "trpc.group/trpc/trpc-protocol/pb/go/trpc/api"; 29 | option java_package = "com.tencent.trpc.protobuf.ext"; 30 | 31 | message HttpRule { 32 | // Selects a method to which this rule applies. 33 | // 34 | // Refer to [selector][google.api.DocumentationRule.selector] for syntax details. 35 | string selector = 1; 36 | 37 | // Determines the URL pattern is matched by this rules. This pattern can be 38 | // used with any of the {get|put|post|delete|patch} methods. A custom method 39 | // can be defined using the 'custom' field. 40 | oneof pattern { 41 | // Maps to HTTP GET. Used for listing and getting information about 42 | // resources. 43 | string get = 2; 44 | 45 | // Maps to HTTP PUT. Used for replacing a resource. 46 | string put = 3; 47 | 48 | // Maps to HTTP POST. Used for creating a resource or performing an action. 49 | string post = 4; 50 | 51 | // Maps to HTTP DELETE. Used for deleting a resource. 52 | string delete = 5; 53 | 54 | // Maps to HTTP PATCH. Used for updating a resource. 55 | string patch = 6; 56 | 57 | // The custom pattern is used for specifying an HTTP method that is not 58 | // included in the `pattern` field, such as HEAD, or "*" to leave the 59 | // HTTP method unspecified for this rule. The wild-card rule is useful 60 | // for services that provide content to Web (HTML) clients. 61 | CustomHttpPattern custom = 8; 62 | } 63 | 64 | // The name of the request field whose value is mapped to the HTTP request 65 | // body, or `*` for mapping all request fields not captured by the path 66 | // pattern to the HTTP body, or omitted for not having any HTTP request body. 67 | // 68 | // NOTE: the referred field must be present at the top-level of the request 69 | // message type. 70 | string body = 7; 71 | 72 | // Optional. The name of the response field whose value is mapped to the HTTP 73 | // response body. When omitted, the entire response message will be used 74 | // as the HTTP response body. 75 | // 76 | // NOTE: The referred field must be present at the top-level of the response 77 | // message type. 78 | string response_body = 12; 79 | 80 | // Additional HTTP bindings for the selector. Nested bindings must 81 | // not contain an `additional_bindings` field themselves (that is, 82 | // the nesting may only be one level deep). 83 | repeated HttpRule additional_bindings = 11; 84 | } 85 | 86 | // A custom pattern is used for defining custom HTTP verb. 87 | message CustomHttpPattern { 88 | // The name of this custom HTTP verb. 89 | string kind = 1; 90 | 91 | // The path matched by this custom verb. 92 | string path = 2; 93 | } 94 | -------------------------------------------------------------------------------- /trpc/api/openapiv2.proto: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making tRPC available. 2 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved. 3 | // If you have downloaded a copy of the tRPC source code from Tencent, 4 | // please note that tRPC source code is licensed under the Apache 2.0 License, 5 | // A copy of the Apache 2.0 License is included in this file. 6 | 7 | syntax = "proto3"; 8 | 9 | package trpc.api; 10 | 11 | option go_package = "trpc.group/trpc/trpc-protocol/pb/go/trpc/api"; 12 | option java_package = "com.tencent.trpc.protobuf.ext"; 13 | 14 | // message option schema 15 | message Schema { 16 | JSONSchema json_schema = 1; 17 | } 18 | 19 | // `JSONSchema` represents properties from JSON SCHEMA taken,and as used, in 20 | // the OpenAPI v2 spec. 21 | message JSONSchema { 22 | repeated string required = 1; 23 | } 24 | -------------------------------------------------------------------------------- /trpc/proto/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | proto_library( 4 | name = "trpc_options_proto", 5 | srcs = [ 6 | "trpc_options.proto", 7 | ], 8 | deps = [ 9 | "@com_google_protobuf//:descriptor_proto", 10 | ], 11 | ) 12 | -------------------------------------------------------------------------------- /trpc/proto/trpc_options.proto: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making tRPC available. 2 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved. 3 | // If you have downloaded a copy of the tRPC source code from Tencent, 4 | // please note that tRPC source code is licensed under the Apache 2.0 License, 5 | // A copy of the Apache 2.0 License is included in this file. 6 | 7 | syntax = "proto3"; 8 | 9 | import "google/protobuf/descriptor.proto"; 10 | 11 | package trpc; 12 | 13 | option go_package = "trpc.group/trpc/trpc-protocol/pb/go/trpc/proto"; 14 | option java_package = "com.tencent.trpc.protobuf.ext"; 15 | 16 | extend google.protobuf.MethodOptions { 17 | string alias = 50001; 18 | } 19 | 20 | extend google.protobuf.FieldOptions { 21 | string go_tag = 50050; 22 | } 23 | -------------------------------------------------------------------------------- /trpc/reflection/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | proto_library( 4 | name = "reflection_proto", 5 | srcs = [ 6 | "reflection.proto", 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /trpc/reflection/reflection.proto: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making tRPC available. 2 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved. 3 | // If you have downloaded a copy of the tRPC source code from Tencent, 4 | // please note that tRPC source code is licensed under the Apache 2.0 License, 5 | // A copy of the Apache 2.0 License is included in this file. 6 | 7 | syntax = "proto3"; 8 | 9 | package trpc.reflection.v1; 10 | 11 | option go_package = "trpc.group/trpc/trpc-protocol/pb/go/trpc/reflection"; 12 | option java_package = "com.tencent.trpc.protobuf.ext"; 13 | 14 | service ServerReflection { 15 | rpc ServiceReflectionInfo (ServerReflectionRequest) returns (ServerReflectionResponse); 16 | } 17 | 18 | // The message sent by the client when calling ServerReflectionInfo method. 19 | message ServerReflectionRequest { 20 | string host = 1; 21 | // To use reflection service, the client should set one of the following 22 | // fields in message_request. The server distinguishes requests by their 23 | // defined field and then handles them using corresponding methods. 24 | oneof message_request { 25 | // Find the proto file that declares the given fully-qualified symbol name. 26 | // This field should be a fully-qualified symbol name 27 | // (e.g. .[.] or .). 28 | string file_containing_symbol = 3; 29 | 30 | // List the full names of registered services. The content will not be 31 | // checked. 32 | string list_services = 4; 33 | 34 | // Find a proto file by the file name. 35 | string file_by_filename = 5; 36 | }; 37 | } 38 | 39 | 40 | // The message sent by the server to answer ServerReflectionInfo method. 41 | message ServerReflectionResponse { 42 | string valid_host = 1; 43 | ServerReflectionRequest original_request = 2; 44 | // The server sets one of the following fields according to the message_request 45 | // in the request. 46 | oneof message_response { 47 | // This message is used to answer file_containing_symbol, 48 | // As the repeated label is not allowed in oneof fields, we use a 49 | // FileDescriptorResponse message to encapsulate the repeated fields. 50 | FileDescriptorResponse file_descriptor_response = 4; 51 | // This message is used to answer list_services requests. 52 | ListServiceResponse list_services_response = 5; 53 | // This message is used when an error occurs. 54 | ErrorResponse error_response = 6; 55 | } 56 | } 57 | 58 | // Serialized FileDescriptorProto messages sent by the server answering 59 | // a file_by_filename, file_containing_symbol, or file_containing_extension 60 | // request. 61 | message FileDescriptorResponse { 62 | // Serialized FileDescriptorProto messages. We avoid taking a dependency on 63 | // descriptor.proto, which uses proto2 only features, by making them opaque 64 | // bytes instead. 65 | repeated bytes file_descriptor_proto = 1; 66 | } 67 | 68 | 69 | // A list of ServiceResponse sent by the server answering list_services request. 70 | message ListServiceResponse { 71 | // The information of each service may be expanded in the future, so we use 72 | // ServiceResponse message to encapsulate it. 73 | repeated ServiceResponse service = 1; 74 | } 75 | 76 | // The information of a single service used by ListServiceResponse to answer 77 | // list_services request. 78 | message ServiceResponse { 79 | // Full name of a registered service, including its package name. 80 | // The format is . 81 | // https://github.com/trpc-group/trpc/blob/master/trpc/trpc.proto#L465 package.Service 82 | string interface_service_name = 1; 83 | // eg: polaris, 123 platform format: trpc.app.server.service. 84 | string routing_service_name = 2; 85 | } 86 | 87 | // The error code and error message sent by the server when an error occurs. 88 | message ErrorResponse { 89 | // This field uses the error codes defined in trpc.proto TrpcRetCode. 90 | int32 error_code = 1; 91 | string error_message = 2; 92 | } 93 | 94 | -------------------------------------------------------------------------------- /trpc/swagger/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | proto_library( 4 | name = "swagger_proto", 5 | srcs = [ 6 | "swagger.proto", 7 | ], 8 | deps = [ 9 | "@com_google_protobuf//:descriptor_proto", 10 | ], 11 | ) 12 | -------------------------------------------------------------------------------- /trpc/swagger/swagger.proto: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making tRPC available. 2 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved. 3 | // If you have downloaded a copy of the tRPC source code from Tencent, 4 | // please note that tRPC source code is licensed under the Apache 2.0 License, 5 | // A copy of the Apache 2.0 License is included in this file. 6 | 7 | syntax = "proto3"; 8 | 9 | import "google/protobuf/descriptor.proto"; 10 | package trpc; 11 | 12 | option go_package = "trpc.group/trpc/trpc-protocol/pb/go/trpc/swagger"; 13 | option java_package = "com.tencent.trpc.protobuf.ext"; 14 | 15 | extend google.protobuf.MethodOptions { 16 | SwaggerRule swagger = 50101; 17 | } 18 | 19 | // to gen swagger json 20 | message SwaggerRule { 21 | string title = 50103; 22 | string method = 50104; 23 | string description = 50105; 24 | repeated SwaggerParam params = 50106; 25 | } 26 | 27 | message SwaggerParam { 28 | string name = 1; 29 | bool required = 2; 30 | string default = 3; 31 | } -------------------------------------------------------------------------------- /trpc/v2/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | proto_library( 4 | name = "trpc_proto", 5 | srcs = [ 6 | "trpc.proto", 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /trpc/v2/api/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | proto_library( 4 | name = "annotations_proto", 5 | srcs = [ 6 | "annotations.proto", 7 | ], 8 | deps = [ 9 | "//trpc/v2/api:http_proto", 10 | "@com_google_protobuf//:descriptor_proto", 11 | ], 12 | ) 13 | 14 | proto_library( 15 | name = "http_proto", 16 | srcs = [ 17 | "http.proto", 18 | ], 19 | ) 20 | -------------------------------------------------------------------------------- /trpc/v2/api/annotations.proto: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making tRPC available. 2 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved. 3 | // If you have downloaded a copy of the tRPC source code from Tencent, 4 | // please note that tRPC source code is licensed under the Apache 2.0 License, 5 | // A copy of the Apache 2.0 License is included in this file. 6 | 7 | syntax = "proto3"; 8 | 9 | package trpc.v2.api; 10 | 11 | import "trpc/v2/api/http.proto"; 12 | import "google/protobuf/descriptor.proto"; 13 | 14 | option go_package = "trpc.group/trpc/trpc-protocol/pb/go/trpc/v2/api"; 15 | option java_package = "com.tencent.trpc.protobuf.ext"; 16 | 17 | extend google.protobuf.MethodOptions { 18 | HttpRule http = 1157; 19 | } 20 | -------------------------------------------------------------------------------- /trpc/v2/api/http.proto: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making tRPC available. 2 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved. 3 | // If you have downloaded a copy of the tRPC source code from Tencent, 4 | // please note that tRPC source code is licensed under the Apache 2.0 License, 5 | // A copy of the Apache 2.0 License is included in this file. 6 | 7 | syntax = "proto3"; 8 | 9 | package trpc.v2.api; 10 | 11 | option go_package = "trpc.group/trpc/trpc-protocol/pb/go/trpc/v2/api"; 12 | option java_package = "com.tencent.trpc.protobuf.ext"; 13 | 14 | message HttpRule { 15 | // Selects a method to which this rule applies. 16 | // 17 | // Refer to [selector][google.api.DocumentationRule.selector] for syntax details. 18 | string selector = 1; 19 | 20 | // Determines the URL pattern is matched by this rules. This pattern can be 21 | // used with any of the {get|put|post|delete|patch} methods. A custom method 22 | // can be defined using the 'custom' field. 23 | oneof pattern { 24 | // Maps to HTTP GET. Used for listing and getting information about 25 | // resources. 26 | string get = 2; 27 | 28 | // Maps to HTTP PUT. Used for replacing a resource. 29 | string put = 3; 30 | 31 | // Maps to HTTP POST. Used for creating a resource or performing an action. 32 | string post = 4; 33 | 34 | // Maps to HTTP DELETE. Used for deleting a resource. 35 | string delete = 5; 36 | 37 | // Maps to HTTP PATCH. Used for updating a resource. 38 | string patch = 6; 39 | 40 | // The custom pattern is used for specifying an HTTP method that is not 41 | // included in the `pattern` field, such as HEAD, or "*" to leave the 42 | // HTTP method unspecified for this rule. The wild-card rule is useful 43 | // for services that provide content to Web (HTML) clients. 44 | CustomHttpPattern custom = 8; 45 | } 46 | 47 | // The name of the request field whose value is mapped to the HTTP request 48 | // body, or `*` for mapping all request fields not captured by the path 49 | // pattern to the HTTP body, or omitted for not having any HTTP request body. 50 | // 51 | // NOTE: the referred field must be present at the top-level of the request 52 | // message type. 53 | string body = 7; 54 | 55 | // Optional. The name of the response field whose value is mapped to the HTTP 56 | // response body. When omitted, the entire response message will be used 57 | // as the HTTP response body. 58 | // 59 | // NOTE: The referred field must be present at the top-level of the response 60 | // message type. 61 | string response_body = 12; 62 | 63 | // Additional HTTP bindings for the selector. Nested bindings must 64 | // not contain an `additional_bindings` field themselves (that is, 65 | // the nesting may only be one level deep). 66 | repeated HttpRule additional_bindings = 11; 67 | } 68 | 69 | // A custom pattern is used for defining custom HTTP verb. 70 | message CustomHttpPattern { 71 | // The name of this custom HTTP verb. 72 | string kind = 1; 73 | 74 | // The path matched by this custom verb. 75 | string path = 2; 76 | } 77 | -------------------------------------------------------------------------------- /trpc/v2/proto/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | proto_library( 4 | name = "trpc_options_proto", 5 | srcs = [ 6 | "trpc_options.proto", 7 | ], 8 | deps = [ 9 | "@com_google_protobuf//:descriptor_proto", 10 | ], 11 | ) 12 | -------------------------------------------------------------------------------- /trpc/v2/proto/trpc_options.proto: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making tRPC available. 2 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved. 3 | // If you have downloaded a copy of the tRPC source code from Tencent, 4 | // please note that tRPC source code is licensed under the Apache 2.0 License, 5 | // A copy of the Apache 2.0 License is included in this file. 6 | 7 | syntax = "proto3"; 8 | 9 | import "google/protobuf/descriptor.proto"; 10 | 11 | package trpc.v2; 12 | 13 | option go_package = "trpc.group/trpc/trpc-protocol/pb/go/trpc/v2/proto"; 14 | option java_package = "com.tencent.trpc.protobuf.ext"; 15 | 16 | extend google.protobuf.MethodOptions { 17 | string alias = 1155; 18 | } 19 | 20 | extend google.protobuf.FieldOptions { 21 | string go_tag = 1156; 22 | } 23 | -------------------------------------------------------------------------------- /trpc/v2/swagger/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | proto_library( 4 | name = "swagger_proto", 5 | srcs = [ 6 | "swagger.proto", 7 | ], 8 | deps = [ 9 | "@com_google_protobuf//:descriptor_proto", 10 | ], 11 | ) 12 | -------------------------------------------------------------------------------- /trpc/v2/swagger/swagger.proto: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making tRPC available. 2 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved. 3 | // If you have downloaded a copy of the tRPC source code from Tencent, 4 | // please note that tRPC source code is licensed under the Apache 2.0 License, 5 | // A copy of the Apache 2.0 License is included in this file. 6 | 7 | syntax = "proto3"; 8 | import "google/protobuf/descriptor.proto"; 9 | package trpc.v2; 10 | 11 | option go_package = "trpc.group/trpc/trpc-protocol/pb/go/trpc/v2/swagger"; 12 | option java_package = "com.tencent.trpc.protobuf.ext"; 13 | 14 | extend google.protobuf.MethodOptions { 15 | SwaggerRule swagger = 1156; 16 | } 17 | 18 | // to gen swagger json 19 | message SwaggerRule { 20 | string title = 50103; 21 | string method = 50104; 22 | string description = 50105; 23 | repeated SwaggerParam params = 50106; 24 | } 25 | 26 | message SwaggerParam { 27 | string name = 1; 28 | bool required = 2; 29 | string default = 3; 30 | } -------------------------------------------------------------------------------- /trpc/v2/validate/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | proto_library( 4 | name = "validate_proto", 5 | srcs = [ 6 | "validate.proto", 7 | ], 8 | deps = [ 9 | "@com_google_protobuf//:descriptor_proto", 10 | "@com_google_protobuf//:duration_proto", 11 | "@com_google_protobuf//:timestamp_proto", 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /trpc/validate/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | proto_library( 4 | name = "validate_proto", 5 | srcs = [ 6 | "validate.proto", 7 | ], 8 | deps = [ 9 | "@com_google_protobuf//:descriptor_proto", 10 | "@com_google_protobuf//:duration_proto", 11 | "@com_google_protobuf//:timestamp_proto", 12 | ], 13 | ) 14 | --------------------------------------------------------------------------------