├── .gitattributes ├── .github ├── ISSUE_TEMPLATE.md ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── custom.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── deploy-framework-docker.yml │ ├── deploy-latest-framework-docker.yml │ ├── deploy-latest-tars-docker.yml │ └── deploy-tars-docker.yml ├── .gitignore ├── .gitmodules ├── Contributing.md ├── LICENSE ├── PerfTestSoft ├── Readme.md ├── StressBenchmark │ ├── README.md │ ├── TarsStressClient │ │ ├── Stress.h │ │ ├── main.cpp │ │ ├── makefile │ │ └── teststress.sh │ └── TarsStressServer │ │ ├── Stress.tars │ │ ├── StressImp.cpp │ │ ├── StressImp.h │ │ ├── TarsStressServer.cpp │ │ ├── TarsStressServer.h │ │ └── makefile └── introduction.md ├── README.md ├── README.zh.md ├── tag.sh ├── tars-deploy-framework.sh ├── tars-deploy-tars.sh ├── tars-latest-deploy-framework.sh └── tars-latest-deploy-tars.sh /.gitattributes: -------------------------------------------------------------------------------- 1 | * linguist-language=C++ 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### What language are you using? 2 | 3 | 4 | ### What operating system (Linux, Ubuntu, …) and version? 5 | 6 | 7 | ### What runtime / compiler are you using (e.g. jdk version or version of gcc) 8 | 9 | 10 | Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs). 11 | 12 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[BUG]" 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **What version of TARS and what language are you using?** 11 | 12 | **What operating system (Linux, Windows, ...) and version?** [e.g. CentOS 7.8] 13 | 14 | **What runtime/compiler are you using?** [e.g. JDK version or version of gcc] 15 | 16 | **Describe the bug** 17 | A clear and concise description of what the bug is. 18 | 19 | **To Reproduce** 20 | Steps to reproduce the behavior: 21 | 1. Go to '...' 22 | 2. Click on '....' 23 | 3. See error 24 | 25 | **Expected behavior** 26 | A clear and concise description of what you expected to happen. 27 | 28 | **Screenshots** 29 | If applicable, add screenshots to help explain your problem. 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Custom issue template 3 | about: Describe this issue template's purpose here. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[FEATURE]" 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | **IMPORTANT: Please do not create a Pull Request without creating an issue first.** 2 | 3 | *Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of the pull request.* 4 | 5 | Please provide enough information so that others can review your pull request: 6 | 7 | 8 | 9 | Explain the **details** for making this change. What existing problem does the pull request solve? 10 | 11 | 12 | 13 | **Test plan (required)** 14 | 15 | Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. 16 | 17 | 18 | 19 | **Code formatting** 20 | 21 | 22 | 23 | **Closing issues** 24 | 25 | Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if such). 26 | -------------------------------------------------------------------------------- /.github/workflows/deploy-framework-docker.yml: -------------------------------------------------------------------------------- 1 | name: deploy-framework-docker 2 | 3 | on: 4 | push: 5 | tags: 6 | - v* 7 | jobs: 8 | build: 9 | runs-on: ubuntu-20.04 10 | steps: 11 | - name: docker login 12 | run: | 13 | docker login -u ${{ secrets.name }} -p ${{ secrets.pass }} 14 | - name: Get version 15 | id: get_version 16 | run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} 17 | - uses: actions/checkout@v3 18 | with: 19 | submodules: true 20 | - name: deploy docker 21 | run: | 22 | echo $GITHUB_SHA 23 | ./tars-deploy-framework.sh ${{ steps.get_version.outputs.VERSION }} true 24 | -------------------------------------------------------------------------------- /.github/workflows/deploy-latest-framework-docker.yml: -------------------------------------------------------------------------------- 1 | name: deploy-latest-framework-docker 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-20.04 11 | steps: 12 | - name: docker login 13 | run: | 14 | docker login -u ${{ secrets.name }} -p ${{ secrets.pass }} 15 | - uses: actions/checkout@v3 16 | with: 17 | submodules: true 18 | - name: deploy docker 19 | run: | 20 | echo $GITHUB_SHA 21 | ./tars-latest-deploy-framework.sh true 22 | -------------------------------------------------------------------------------- /.github/workflows/deploy-latest-tars-docker.yml: -------------------------------------------------------------------------------- 1 | name: deploy-latest-tars-docker 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | jobs: 8 | build: 9 | runs-on: ubuntu-20.04 10 | steps: 11 | - name: docker login 12 | run: | 13 | docker login -u ${{ secrets.name }} -p ${{ secrets.pass }} 14 | - uses: actions/checkout@v3 15 | with: 16 | submodules: true 17 | - name: deploy docker 18 | run: | 19 | echo $GITHUB_SHA 20 | ./tars-latest-deploy-tars.sh true 21 | -------------------------------------------------------------------------------- /.github/workflows/deploy-tars-docker.yml: -------------------------------------------------------------------------------- 1 | name: deploy-tars-docker 2 | 3 | on: 4 | push: 5 | tags: 6 | - v* 7 | jobs: 8 | build: 9 | runs-on: ubuntu-20.04 10 | steps: 11 | - name: docker login 12 | run: | 13 | docker login -u ${{ secrets.name }} -p ${{ secrets.pass }} 14 | - name: Get version 15 | id: get_version 16 | run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} 17 | - uses: actions/checkout@v3 18 | with: 19 | submodules: true 20 | - name: deploy docker 21 | run: | 22 | echo $GITHUB_SHA 23 | ./tars-deploy-tars.sh ${{ steps.get_version.outputs.VERSION }} true 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /java/core/.settings 2 | /java/core/.classpath 3 | /java/core/.project 4 | /java/examples/quickstart-client/.settings 5 | /java/examples/quickstart-client/.project 6 | /java/examples/quickstart-client/.classpath 7 | /java/examples/quickstart-server/.settings 8 | /java/examples/quickstart-server/.project 9 | /java/examples/quickstart-server/.classpath 10 | /java/net/.settings 11 | /java/net/.project 12 | /java/net/.classpath 13 | /java/tools/tars-maven-plugin/.settings 14 | /java/tools/tars-maven-plugin/.project 15 | /java/tools/tars-maven-plugin/.classpath 16 | /java/core/target 17 | /java/examples/quickstart-client/target 18 | /java/examples/quickstart-server/target 19 | /java/net/target 20 | /java/tools/tars-maven-plugin/target 21 | /java/examples/stress-server/.classpath 22 | /java/examples/stress-server/.project 23 | /java/examples/stress-server/.settings 24 | /java/examples/stress-server/target 25 | /java/.project 26 | /java/.settings/org.eclipse.m2e.core.prefs 27 | /java/examples/.project 28 | /java/examples/.settings/org.eclipse.m2e.core.prefs 29 | /java/tools/.project 30 | /java/tools/.settings/org.eclipse.m2e.core.prefs 31 | 32 | /php/.idea/* 33 | .idea/* 34 | 35 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "framework"] 2 | path = framework 3 | url = https://github.com/TarsCloud/TarsFramework 4 | [submodule "cpp"] 5 | path = cpp 6 | url = https://github.com/TarsCloud/TarsCpp 7 | [submodule "java"] 8 | path = java 9 | url = https://github.com/TarsCloud/TarsJava 10 | [submodule "nodejs"] 11 | path = nodejs 12 | url = https://github.com/tars-node/Tars.js 13 | [submodule "php"] 14 | path = php 15 | url = https://github.com/TarsPHP/TarsPHP 16 | [submodule "tup"] 17 | path = tup 18 | url = https://github.com/TarsCloud/TarsTup 19 | [submodule "web"] 20 | path = web 21 | url = https://github.com/TarsCloud/TarsWeb 22 | [submodule "go"] 23 | path = go 24 | url = https://github.com/TarsCloud/TarsGo 25 | [submodule "docs"] 26 | path = docs 27 | url = https://github.com/TarsCloud/TarsDocs 28 | [submodule "docker"] 29 | path = docker 30 | url = https://github.com/TarsCloud/TarsDocker.git 31 | [submodule "docs_en"] 32 | path = docs_en 33 | url = https://github.com/TarsCloud/TarsDocs_en 34 | -------------------------------------------------------------------------------- /Contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | If you contributed but cannot find your ID in the file, please submit PR and add your GitHub ID to **both contributing file under your contributed repo** and [Tars repo](https://github.com/TarsCloud/Tars/pulls). 4 | 5 | ## Tars 6 | 7 | ### Committer 8 | 9 | - ruanshudong 10 | - loveyacper 11 | - LawlietLi 12 | - meijing0114 13 | - medns 14 | - dpp2009 15 | - TOKISAKIKURUMI 16 | - change93 17 | - helloopenworld 18 | - meiping 19 | - copyrenzhe 20 | - bobzhangyong 21 | - wjx82850707 22 | - Spacebody 23 | - souldancer 24 | - zerolocusta 25 | - markshan 26 | 27 | ### Contributors List 28 | 29 | - 9chu 30 | - Abioy 31 | - bartdong 32 | - bishaoqing 33 | - bobzhangyong 34 | - change93 35 | - Cnlouds 36 | - copyrenzhe 37 | - cygsxak 38 | - deepzliu 39 | - dolphinxwc 40 | - dpp2009 41 | - duoyu119 42 | - ETZhangSX 43 | - Fr1ck 44 | - ganziqim 45 | - guzitajiu 46 | - helloopenworld 47 | - higithubhi 48 | - isabellavieira 49 | - jerrylucky 50 | - KatharineOzil 51 | - kuangxc 52 | - lanffy 53 | - lanyutc 54 | - LawlietLee 55 | - LawlietLi 56 | - loveyacper 57 | - maplebeats 58 | - marklightning 59 | - mdhender 60 | - medns 61 | - meijing0114 62 | - meiping 63 | - MR-workaholic 64 | - munglechina 65 | - parchk 66 | - qiuxin 67 | - ruanshudong 68 | - sandyskies 69 | - scguoi 70 | - serverlessplus 71 | - songvy 72 | - souldancer 73 | - Spacebody 74 | - sy-records 75 | - tarstest 76 | - TCZWJ 77 | - TimmyYu 78 | - tinkercloud 79 | - TOKISAKIKURUMI 80 | - wjx82850707 81 | - youngdou 82 | - YoungZiyi 83 | - yuansx 84 | - yukkiball 85 | - zehuaiWANG 86 | - zerolocusta 87 | - BeyondWUXF 88 | 89 | ## TarsCpp 90 | 91 | ### Committer 92 | 93 | - ruanshudong 94 | - markshan 95 | 96 | ### Contributors List 97 | 98 | - Abioy 99 | - jerrylucky 100 | - langio 101 | - marklightning 102 | - ruanshudong 103 | - shevqko 104 | - Spacebody 105 | - TCZWJ 106 | - viest 107 | - YMChenLiye 108 | - zhanleewo 109 | - BeyondWUXF 110 | 111 | ## TarsBenchmark 112 | 113 | ### Committer 114 | - forrestlinfeng 115 | - markshan 116 | 117 | ### Contributor List 118 | 119 | - forrestlinfeng 120 | - wincsb 121 | 122 | ## plugins 123 | 124 | - diracccc 125 | 126 | ## TarsDemo 127 | 128 | - ruanshudong 129 | 130 | ## TarsDocker 131 | 132 | ### Committer 133 | 134 | - ruanshudong 135 | - markshan 136 | 137 | ### Contributor List 138 | 139 | - bartdong 140 | - Frankie 141 | - franklee0817 142 | - ruanshudong 143 | - RuizhaoLi 144 | 145 | ## TarsDocs 146 | 147 | ### Committer 148 | 149 | - ruanshudong 150 | - KatharineOzil 151 | - bartdong 152 | - Cnlouds 153 | - markshan 154 | 155 | ### Contributor List 156 | - bartdong 157 | - Cnlouds 158 | - danielzheng-Tencent 159 | - jerrylucky 160 | - KatharineOzil 161 | - meijing0114 162 | - ruanshudong 163 | - yukkiball 164 | - zouchengzhuo 165 | 166 | ## TarsFramework 167 | 168 | ### Committer 169 | 170 | - ruanshudong 171 | - wincsb 172 | - markshan 173 | 174 | ### Contributor List 175 | - diracccc 176 | - ETZhangSX 177 | - jerrylucky 178 | - lanhy 179 | - MindHook 180 | - mygrsun 181 | - renyang9876 182 | - ruanshudong 183 | - shevqko 184 | - wincsb 185 | - ypingcn 186 | - yuansx 187 | - BeyondWUXF 188 | 189 | ## TarsGo 190 | 191 | ### Committer 192 | 193 | - sandyskies 194 | - jchalex 195 | - chenhengqi 196 | - MonkeyLi 197 | - tensorchen 198 | - rikewang 199 | - markshan 200 | - lbbniu 201 | 202 | ### Contributor List 203 | - 0xflotus 204 | - agchrys 205 | - Andrew-M-C 206 | - bartdong 207 | - BurningXFlame 208 | - chenhengqi 209 | - Clark-zhang 210 | - ClaudeLiang 211 | - cokeboL 212 | - defool 213 | - erjanmx 214 | - hooligan520 215 | - hotWing17 216 | - imthx 217 | - jchalex 218 | - jyuan68 219 | - lanhy 220 | - louishlz 221 | - marklightning 222 | - maplebeats 223 | - mdhender 224 | - mjaow 225 | - MonkeyLi 226 | - mountkin 227 | - nickwanninger 228 | - philippgille 229 | - qiuxin 230 | - rbarros 231 | - rikewang 232 | - ruanshudong 233 | - sandyskies 234 | - skelway 235 | - TauWu 236 | - tensorchen 237 | - terryding77 238 | - wqliang 239 | - wzshiming 240 | - xiaoxubeii 241 | - xuri 242 | - YaffaBeauty 243 | - YouEclipse 244 | - lbbniu 245 | - BeyondWUXF 246 | 247 | ## TarsJava 248 | 249 | ### Committer 250 | 251 | - TimmyYu 252 | - XenoAmess 253 | - diracccc 254 | - LawlietLi 255 | - markshan 256 | 257 | ### Contributor List 258 | - diracccc 259 | - kahn 260 | - LawlietLi 261 | - LiuMenghan 262 | - TimmyYu 263 | - walkertest 264 | - woodwind 265 | - XenoAmess 266 | - yukkiball 267 | 268 | ## TarsPHP 269 | 270 | ### Committer 271 | 272 | - meijing0114 273 | - bobzhangyong 274 | - copyrenzhe 275 | - dpp2009 276 | - markshan 277 | 278 | ### Contributor List 279 | - bobzhangyong 280 | - copyrenzhe 281 | - cuixg 282 | - danielzheng-Tencent 283 | - dpp2009 284 | - meijing0114 285 | - wodetian55 286 | - medmin 287 | - sy-records 288 | 289 | ## TarsProtocol 290 | 291 | ### Committer 292 | - ruanshudong 293 | - shevqko 294 | - markshan 295 | 296 | ### Contributor List 297 | - jerrylucky 298 | - ruanshudong 299 | - shevqko 300 | - hpeiy98 301 | 302 | ## TarsWeb 303 | 304 | ### Committer 305 | - ruanshudong 306 | - zouchengzhuo 307 | - ziyang314 308 | - shevqko 309 | - markshan 310 | 311 | ### Contributor List 312 | - airycanon 313 | - ETZhangSX 314 | - jerrylucky 315 | - lanhy 316 | - ouliuquan 317 | - ruanshudong 318 | - sandyskies 319 | - shevqko 320 | - wjx82850707 321 | - ypingcn 322 | - ziyang314 323 | - zouchengzhuo 324 | - BeyondWUXF 325 | 326 | ## TarsJMeter 327 | 328 | ### Committer 329 | 330 | - boycs007 331 | - jnlunsb 332 | - markshan 333 | 334 | 335 | ### Contributor List 336 | - boycs007 337 | - jnlunsb 338 | - juliuslu-tencent 339 | 340 | ## TarsNodeJS 341 | 342 | ### Committer 343 | 344 | - medmin 345 | - markshan 346 | 347 | ### Contributor List 348 | 349 | - medmin 350 | 351 | ## K8STARS 352 | ### Committer 353 | - bartdong 354 | - defool 355 | - markshan 356 | 357 | ### Contributor List 358 | 359 | - bartdong 360 | - defool 361 | - hpeiy98 362 | - KatharineOzil 363 | - andyguo1023 364 | 365 | ## ArtWork 366 | 367 | - cheney-ying 368 | - heisewuyu16 369 | - Quentin-by 370 | 371 | ## TarsTools 372 | 373 | ### Committer 374 | - harveyxu-tme 375 | - markshan 376 | 377 | ### Contributor List 378 | 379 | - harveyxu-tme 380 | - hpeiy98 381 | 382 | ## TarsGateway 383 | 384 | ### Committer 385 | 386 | - shevqko 387 | - markshan 388 | 389 | ### Contributor List 390 | 391 | - shevqko 392 | - ruanshudong 393 | - hpeiy98 394 | - wincsb 395 | 396 | ## TARS_Landscape 397 | 398 | ### Committer 399 | 400 | - KatharineOzil 401 | - dankohn 402 | 403 | ### Contributor List 404 | 405 | - KatharineOzil 406 | - dankohn 407 | - bartdong 408 | - jordinl83 409 | - heisewuyu16 410 | 411 | ## TarsprotocolProxy 412 | 413 | ### Committer 414 | 415 | - shevqko 416 | - eatonzhang 417 | - markshan 418 | 419 | ### Contributor List 420 | 421 | - shevqko 422 | - eatonzhang 423 | - markshan 424 | - hpeiy98 425 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2020, THE TARS FOUNDATION 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /PerfTestSoft/Readme.md: -------------------------------------------------------------------------------- 1 | # Table of contents 2 | > * [1.Description](#main-chapter-1) 3 | > * [2.Framework Environment Setup](#main-chapter-2) 4 | > * [3.Server Side Test Software](#main-chapter-3) 5 | > * [4.Client Side Test Software](#main-chapter-4) 6 | > * [5.Note Well](#main-chapter-5) 7 | 8 | # 1. Description 9 | - This folder is used to store the software for Tars performance Test. 10 | - The test software consists of the client software and the server software. 11 | - The Tars framework should be set up successfully prior to run the performance test software. 12 | 13 | 14 | # 2. Tars Framework Environment Setup 15 | - In order to run the performance test, Tars framework is a must. 16 | - You can setup the framework via script or do it step-by-step. 17 | - Refer to the following link: 18 | - https://github.com/TarsCloud/Tars/tree/master/shellDeploy 19 | - https://github.com/TarsCloud/Tars#installation 20 | 21 | 22 | # 3. Server Side Test Software 23 | - For the server side, 24 | 25 | 26 | # 4. Client Side Test Software 27 | - For the client side, 28 | 29 | 30 | 31 | # 5. Note Well 32 | - More informations you should pay special attention to. 33 | -------------------------------------------------------------------------------- /PerfTestSoft/StressBenchmark/README.md: -------------------------------------------------------------------------------- 1 | 该工程是Tars入门示例的代码 2 | 3 | 4 | 目录名称 |功能 5 | -----------------|---------------- 6 | TarsStressServer | Tars性能压测服务端的程序 7 | TarsStressClient | Tars性能压测客户端的程序 8 | -------------------------------------------------------------------------------- /PerfTestSoft/StressBenchmark/TarsStressClient/Stress.h: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // This file was generated by a TARS parser! 3 | // TARS version 1.1.0. 4 | // ********************************************************************** 5 | 6 | #ifndef __STRESS_H_ 7 | #define __STRESS_H_ 8 | 9 | #include 10 | #include 11 | #include 12 | #include "tup/Tars.h" 13 | using namespace std; 14 | #include "servant/ServantProxy.h" 15 | #include "servant/Servant.h" 16 | #include "promise/promise.h" 17 | 18 | 19 | namespace Test 20 | { 21 | 22 | /* callback of async proxy for client */ 23 | class StressPrxCallback: public tars::ServantProxyCallback 24 | { 25 | public: 26 | virtual ~StressPrxCallback(){} 27 | virtual void callback_test(tars::Int32 ret) 28 | { throw std::runtime_error("callback_test() override incorrect."); } 29 | virtual void callback_test_exception(tars::Int32 ret) 30 | { throw std::runtime_error("callback_test_exception() override incorrect."); } 31 | 32 | virtual void callback_testStr(tars::Int32 ret, const std::string& sOut) 33 | { throw std::runtime_error("callback_testStr() override incorrect."); } 34 | virtual void callback_testStr_exception(tars::Int32 ret) 35 | { throw std::runtime_error("callback_testStr_exception() override incorrect."); } 36 | 37 | public: 38 | virtual const map & getResponseContext() const 39 | { 40 | CallbackThreadData * pCbtd = CallbackThreadData::getData(); 41 | assert(pCbtd != NULL); 42 | 43 | if(!pCbtd->getContextValid()) 44 | { 45 | throw TC_Exception("cann't get response context"); 46 | } 47 | return pCbtd->getResponseContext(); 48 | } 49 | 50 | public: 51 | virtual int onDispatch(tars::ReqMessagePtr msg) 52 | { 53 | static ::std::string __Stress_all[]= 54 | { 55 | "test", 56 | "testStr" 57 | }; 58 | pair r = equal_range(__Stress_all, __Stress_all+2, string(msg->request.sFuncName)); 59 | if(r.first == r.second) return tars::TARSSERVERNOFUNCERR; 60 | switch(r.first - __Stress_all) 61 | { 62 | case 0: 63 | { 64 | if (msg->response.iRet != tars::TARSSERVERSUCCESS) 65 | { 66 | callback_test_exception(msg->response.iRet); 67 | 68 | return msg->response.iRet; 69 | } 70 | tars::TarsInputStream _is; 71 | 72 | _is.setBuffer(msg->response.sBuffer); 73 | tars::Int32 _ret; 74 | _is.read(_ret, 0, true); 75 | 76 | CallbackThreadData * pCbtd = CallbackThreadData::getData(); 77 | assert(pCbtd != NULL); 78 | 79 | pCbtd->setResponseContext(msg->response.context); 80 | 81 | callback_test(_ret); 82 | 83 | pCbtd->delResponseContext(); 84 | 85 | return tars::TARSSERVERSUCCESS; 86 | 87 | } 88 | case 1: 89 | { 90 | if (msg->response.iRet != tars::TARSSERVERSUCCESS) 91 | { 92 | callback_testStr_exception(msg->response.iRet); 93 | 94 | return msg->response.iRet; 95 | } 96 | tars::TarsInputStream _is; 97 | 98 | _is.setBuffer(msg->response.sBuffer); 99 | tars::Int32 _ret; 100 | _is.read(_ret, 0, true); 101 | 102 | std::string sOut; 103 | _is.read(sOut, 2, true); 104 | CallbackThreadData * pCbtd = CallbackThreadData::getData(); 105 | assert(pCbtd != NULL); 106 | 107 | pCbtd->setResponseContext(msg->response.context); 108 | 109 | callback_testStr(_ret, sOut); 110 | 111 | pCbtd->delResponseContext(); 112 | 113 | return tars::TARSSERVERSUCCESS; 114 | 115 | } 116 | } 117 | return tars::TARSSERVERNOFUNCERR; 118 | } 119 | 120 | }; 121 | typedef tars::TC_AutoPtr StressPrxCallbackPtr; 122 | 123 | /* callback of promise async proxy for client */ 124 | class StressPrxCallbackPromise: public tars::ServantProxyCallback 125 | { 126 | public: 127 | virtual ~StressPrxCallbackPromise(){} 128 | public: 129 | struct Promisetest: virtual public TC_HandleBase 130 | { 131 | public: 132 | tars::Int32 _ret; 133 | map _mRspContext; 134 | }; 135 | 136 | typedef tars::TC_AutoPtr< StressPrxCallbackPromise::Promisetest > PromisetestPtr; 137 | 138 | StressPrxCallbackPromise(const promise::Promise< StressPrxCallbackPromise::PromisetestPtr > &promise) 139 | : _promise_test(promise) 140 | {} 141 | 142 | virtual void callback_test(const StressPrxCallbackPromise::PromisetestPtr &ptr) 143 | { 144 | _promise_test.setValue(ptr); 145 | } 146 | virtual void callback_test_exception(tars::Int32 ret) 147 | { 148 | std::string str(""); 149 | str += "Function:test_exception|Ret:"; 150 | str += TC_Common::tostr(ret); 151 | _promise_test.setException(promise::copyException(str, ret)); 152 | } 153 | 154 | protected: 155 | promise::Promise< StressPrxCallbackPromise::PromisetestPtr > _promise_test; 156 | 157 | public: 158 | struct PromisetestStr: virtual public TC_HandleBase 159 | { 160 | public: 161 | tars::Int32 _ret; 162 | std::string sOut; 163 | map _mRspContext; 164 | }; 165 | 166 | typedef tars::TC_AutoPtr< StressPrxCallbackPromise::PromisetestStr > PromisetestStrPtr; 167 | 168 | StressPrxCallbackPromise(const promise::Promise< StressPrxCallbackPromise::PromisetestStrPtr > &promise) 169 | : _promise_testStr(promise) 170 | {} 171 | 172 | virtual void callback_testStr(const StressPrxCallbackPromise::PromisetestStrPtr &ptr) 173 | { 174 | _promise_testStr.setValue(ptr); 175 | } 176 | virtual void callback_testStr_exception(tars::Int32 ret) 177 | { 178 | std::string str(""); 179 | str += "Function:testStr_exception|Ret:"; 180 | str += TC_Common::tostr(ret); 181 | _promise_testStr.setException(promise::copyException(str, ret)); 182 | } 183 | 184 | protected: 185 | promise::Promise< StressPrxCallbackPromise::PromisetestStrPtr > _promise_testStr; 186 | 187 | public: 188 | virtual int onDispatch(tars::ReqMessagePtr msg) 189 | { 190 | static ::std::string __Stress_all[]= 191 | { 192 | "test", 193 | "testStr" 194 | }; 195 | 196 | pair r = equal_range(__Stress_all, __Stress_all+2, string(msg->request.sFuncName)); 197 | if(r.first == r.second) return tars::TARSSERVERNOFUNCERR; 198 | switch(r.first - __Stress_all) 199 | { 200 | case 0: 201 | { 202 | if (msg->response.iRet != tars::TARSSERVERSUCCESS) 203 | { 204 | callback_test_exception(msg->response.iRet); 205 | 206 | return msg->response.iRet; 207 | } 208 | tars::TarsInputStream _is; 209 | 210 | _is.setBuffer(msg->response.sBuffer); 211 | 212 | StressPrxCallbackPromise::PromisetestPtr ptr = new StressPrxCallbackPromise::Promisetest(); 213 | 214 | try 215 | { 216 | _is.read(ptr->_ret, 0, true); 217 | 218 | } 219 | catch(std::exception &ex) 220 | { 221 | callback_test_exception(tars::TARSCLIENTDECODEERR); 222 | 223 | return tars::TARSCLIENTDECODEERR; 224 | } 225 | catch(...) 226 | { 227 | callback_test_exception(tars::TARSCLIENTDECODEERR); 228 | 229 | return tars::TARSCLIENTDECODEERR; 230 | } 231 | 232 | ptr->_mRspContext = msg->response.context; 233 | 234 | callback_test(ptr); 235 | 236 | return tars::TARSSERVERSUCCESS; 237 | 238 | } 239 | case 1: 240 | { 241 | if (msg->response.iRet != tars::TARSSERVERSUCCESS) 242 | { 243 | callback_testStr_exception(msg->response.iRet); 244 | 245 | return msg->response.iRet; 246 | } 247 | tars::TarsInputStream _is; 248 | 249 | _is.setBuffer(msg->response.sBuffer); 250 | 251 | StressPrxCallbackPromise::PromisetestStrPtr ptr = new StressPrxCallbackPromise::PromisetestStr(); 252 | 253 | try 254 | { 255 | _is.read(ptr->_ret, 0, true); 256 | 257 | _is.read(ptr->sOut, 2, true); 258 | } 259 | catch(std::exception &ex) 260 | { 261 | callback_testStr_exception(tars::TARSCLIENTDECODEERR); 262 | 263 | return tars::TARSCLIENTDECODEERR; 264 | } 265 | catch(...) 266 | { 267 | callback_testStr_exception(tars::TARSCLIENTDECODEERR); 268 | 269 | return tars::TARSCLIENTDECODEERR; 270 | } 271 | 272 | ptr->_mRspContext = msg->response.context; 273 | 274 | callback_testStr(ptr); 275 | 276 | return tars::TARSSERVERSUCCESS; 277 | 278 | } 279 | } 280 | return tars::TARSSERVERNOFUNCERR; 281 | } 282 | 283 | }; 284 | typedef tars::TC_AutoPtr StressPrxCallbackPromisePtr; 285 | 286 | /* callback of coroutine async proxy for client */ 287 | class StressCoroPrxCallback: public StressPrxCallback 288 | { 289 | public: 290 | virtual ~StressCoroPrxCallback(){} 291 | public: 292 | virtual const map & getResponseContext() const { return _mRspContext; } 293 | 294 | virtual void setResponseContext(const map &mContext) { _mRspContext = mContext; } 295 | 296 | public: 297 | int onDispatch(tars::ReqMessagePtr msg) 298 | { 299 | static ::std::string __Stress_all[]= 300 | { 301 | "test", 302 | "testStr" 303 | }; 304 | 305 | pair r = equal_range(__Stress_all, __Stress_all+2, string(msg->request.sFuncName)); 306 | if(r.first == r.second) return tars::TARSSERVERNOFUNCERR; 307 | switch(r.first - __Stress_all) 308 | { 309 | case 0: 310 | { 311 | if (msg->response.iRet != tars::TARSSERVERSUCCESS) 312 | { 313 | callback_test_exception(msg->response.iRet); 314 | 315 | return msg->response.iRet; 316 | } 317 | tars::TarsInputStream _is; 318 | 319 | _is.setBuffer(msg->response.sBuffer); 320 | try 321 | { 322 | tars::Int32 _ret; 323 | _is.read(_ret, 0, true); 324 | 325 | setResponseContext(msg->response.context); 326 | 327 | callback_test(_ret); 328 | 329 | } 330 | catch(std::exception &ex) 331 | { 332 | callback_test_exception(tars::TARSCLIENTDECODEERR); 333 | 334 | return tars::TARSCLIENTDECODEERR; 335 | } 336 | catch(...) 337 | { 338 | callback_test_exception(tars::TARSCLIENTDECODEERR); 339 | 340 | return tars::TARSCLIENTDECODEERR; 341 | } 342 | 343 | return tars::TARSSERVERSUCCESS; 344 | 345 | } 346 | case 1: 347 | { 348 | if (msg->response.iRet != tars::TARSSERVERSUCCESS) 349 | { 350 | callback_testStr_exception(msg->response.iRet); 351 | 352 | return msg->response.iRet; 353 | } 354 | tars::TarsInputStream _is; 355 | 356 | _is.setBuffer(msg->response.sBuffer); 357 | try 358 | { 359 | tars::Int32 _ret; 360 | _is.read(_ret, 0, true); 361 | 362 | std::string sOut; 363 | _is.read(sOut, 2, true); 364 | setResponseContext(msg->response.context); 365 | 366 | callback_testStr(_ret, sOut); 367 | 368 | } 369 | catch(std::exception &ex) 370 | { 371 | callback_testStr_exception(tars::TARSCLIENTDECODEERR); 372 | 373 | return tars::TARSCLIENTDECODEERR; 374 | } 375 | catch(...) 376 | { 377 | callback_testStr_exception(tars::TARSCLIENTDECODEERR); 378 | 379 | return tars::TARSCLIENTDECODEERR; 380 | } 381 | 382 | return tars::TARSSERVERSUCCESS; 383 | 384 | } 385 | } 386 | return tars::TARSSERVERNOFUNCERR; 387 | } 388 | 389 | protected: 390 | map _mRspContext; 391 | }; 392 | typedef tars::TC_AutoPtr StressCoroPrxCallbackPtr; 393 | 394 | /* proxy for client */ 395 | class StressProxy : public tars::ServantProxy 396 | { 397 | public: 398 | typedef map TARS_CONTEXT; 399 | tars::Int32 test(const map &context = TARS_CONTEXT(),map * pResponseContext = NULL) 400 | { 401 | tars::TarsOutputStream _os; 402 | tars::ResponsePacket rep; 403 | std::map _mStatus; 404 | tars_invoke(tars::TARSNORMAL,"test", _os.getByteBuffer(), context, _mStatus, rep); 405 | if(pResponseContext) 406 | { 407 | *pResponseContext = rep.context; 408 | } 409 | 410 | tars::TarsInputStream _is; 411 | _is.setBuffer(rep.sBuffer); 412 | tars::Int32 _ret; 413 | _is.read(_ret, 0, true); 414 | return _ret; 415 | } 416 | 417 | void async_test(StressPrxCallbackPtr callback,const map& context = TARS_CONTEXT()) 418 | { 419 | tars::TarsOutputStream _os; 420 | std::map _mStatus; 421 | tars_invoke_async(tars::TARSNORMAL,"test", _os.getByteBuffer(), context, _mStatus, callback); 422 | } 423 | 424 | promise::Future< StressPrxCallbackPromise::PromisetestPtr > promise_async_test(const map& context) 425 | { 426 | promise::Promise< StressPrxCallbackPromise::PromisetestPtr > promise; 427 | StressPrxCallbackPromisePtr callback = new StressPrxCallbackPromise(promise); 428 | 429 | tars::TarsOutputStream _os; 430 | std::map _mStatus; 431 | tars_invoke_async(tars::TARSNORMAL,"test", _os.getByteBuffer(), context, _mStatus, callback); 432 | 433 | return promise.getFuture(); 434 | } 435 | 436 | void coro_test(StressCoroPrxCallbackPtr callback,const map& context = TARS_CONTEXT()) 437 | { 438 | tars::TarsOutputStream _os; 439 | std::map _mStatus; 440 | tars_invoke_async(tars::TARSNORMAL,"test", _os.getByteBuffer(), context, _mStatus, callback, true); 441 | } 442 | 443 | tars::Int32 testStr(const std::string & sIn,std::string &sOut,const map &context = TARS_CONTEXT(),map * pResponseContext = NULL) 444 | { 445 | tars::TarsOutputStream _os; 446 | _os.write(sIn, 1); 447 | _os.write(sOut, 2); 448 | tars::ResponsePacket rep; 449 | std::map _mStatus; 450 | tars_invoke(tars::TARSNORMAL,"testStr", _os.getByteBuffer(), context, _mStatus, rep); 451 | if(pResponseContext) 452 | { 453 | *pResponseContext = rep.context; 454 | } 455 | 456 | tars::TarsInputStream _is; 457 | _is.setBuffer(rep.sBuffer); 458 | tars::Int32 _ret; 459 | _is.read(_ret, 0, true); 460 | _is.read(sOut, 2, true); 461 | return _ret; 462 | } 463 | 464 | void async_testStr(StressPrxCallbackPtr callback,const std::string &sIn,const map& context = TARS_CONTEXT()) 465 | { 466 | tars::TarsOutputStream _os; 467 | _os.write(sIn, 1); 468 | std::map _mStatus; 469 | tars_invoke_async(tars::TARSNORMAL,"testStr", _os.getByteBuffer(), context, _mStatus, callback); 470 | } 471 | 472 | promise::Future< StressPrxCallbackPromise::PromisetestStrPtr > promise_async_testStr(const std::string &sIn,const map& context) 473 | { 474 | promise::Promise< StressPrxCallbackPromise::PromisetestStrPtr > promise; 475 | StressPrxCallbackPromisePtr callback = new StressPrxCallbackPromise(promise); 476 | 477 | tars::TarsOutputStream _os; 478 | _os.write(sIn, 1); 479 | std::map _mStatus; 480 | tars_invoke_async(tars::TARSNORMAL,"testStr", _os.getByteBuffer(), context, _mStatus, callback); 481 | 482 | return promise.getFuture(); 483 | } 484 | 485 | void coro_testStr(StressCoroPrxCallbackPtr callback,const std::string &sIn,const map& context = TARS_CONTEXT()) 486 | { 487 | tars::TarsOutputStream _os; 488 | _os.write(sIn, 1); 489 | std::map _mStatus; 490 | tars_invoke_async(tars::TARSNORMAL,"testStr", _os.getByteBuffer(), context, _mStatus, callback, true); 491 | } 492 | 493 | StressProxy* tars_hash(int64_t key) 494 | { 495 | return (StressProxy*)ServantProxy::tars_hash(key); 496 | } 497 | 498 | StressProxy* tars_consistent_hash(int64_t key) 499 | { 500 | return (StressProxy*)ServantProxy::tars_consistent_hash(key); 501 | } 502 | 503 | StressProxy* tars_set_timeout(int msecond) 504 | { 505 | return (StressProxy*)ServantProxy::tars_set_timeout(msecond); 506 | } 507 | 508 | }; 509 | typedef tars::TC_AutoPtr StressPrx; 510 | 511 | /* servant for server */ 512 | class Stress : public tars::Servant 513 | { 514 | public: 515 | virtual ~Stress(){} 516 | virtual tars::Int32 test(tars::TarsCurrentPtr current) = 0; 517 | static void async_response_test(tars::TarsCurrentPtr current, tars::Int32 _ret) 518 | { 519 | if (current->getRequestVersion() == TUPVERSION ) 520 | { 521 | UniAttribute tarsAttr; 522 | tarsAttr.setVersion(current->getRequestVersion()); 523 | tarsAttr.put("", _ret); 524 | 525 | vector sTupResponseBuffer; 526 | tarsAttr.encode(sTupResponseBuffer); 527 | current->sendResponse(tars::TARSSERVERSUCCESS, sTupResponseBuffer); 528 | } 529 | else 530 | { 531 | tars::TarsOutputStream _os; 532 | _os.write(_ret, 0); 533 | 534 | current->sendResponse(tars::TARSSERVERSUCCESS, _os.getByteBuffer()); 535 | } 536 | } 537 | 538 | virtual tars::Int32 testStr(const std::string & sIn,std::string &sOut,tars::TarsCurrentPtr current) = 0; 539 | static void async_response_testStr(tars::TarsCurrentPtr current, tars::Int32 _ret, const std::string &sOut) 540 | { 541 | if (current->getRequestVersion() == TUPVERSION ) 542 | { 543 | UniAttribute tarsAttr; 544 | tarsAttr.setVersion(current->getRequestVersion()); 545 | tarsAttr.put("", _ret); 546 | tarsAttr.put("sOut", sOut); 547 | 548 | vector sTupResponseBuffer; 549 | tarsAttr.encode(sTupResponseBuffer); 550 | current->sendResponse(tars::TARSSERVERSUCCESS, sTupResponseBuffer); 551 | } 552 | else 553 | { 554 | tars::TarsOutputStream _os; 555 | _os.write(_ret, 0); 556 | 557 | _os.write(sOut, 2); 558 | 559 | current->sendResponse(tars::TARSSERVERSUCCESS, _os.getByteBuffer()); 560 | } 561 | } 562 | 563 | public: 564 | int onDispatch(tars::TarsCurrentPtr _current, vector &_sResponseBuffer) 565 | { 566 | static ::std::string __Test__Stress_all[]= 567 | { 568 | "test", 569 | "testStr" 570 | }; 571 | 572 | pair r = equal_range(__Test__Stress_all, __Test__Stress_all+2, _current->getFuncName()); 573 | if(r.first == r.second) return tars::TARSSERVERNOFUNCERR; 574 | switch(r.first - __Test__Stress_all) 575 | { 576 | case 0: 577 | { 578 | tars::TarsInputStream _is; 579 | _is.setBuffer(_current->getRequestBuffer()); 580 | if (_current->getRequestVersion() == TUPVERSION) 581 | { 582 | UniAttribute tarsAttr; 583 | tarsAttr.setVersion(_current->getRequestVersion()); 584 | tarsAttr.decode(_current->getRequestBuffer()); 585 | } 586 | else 587 | { 588 | } 589 | tars::Int32 _ret = test(_current); 590 | if(_current->isResponse()) 591 | { 592 | if (_current->getRequestVersion() == TUPVERSION ) 593 | { 594 | UniAttribute tarsAttr; 595 | tarsAttr.setVersion(_current->getRequestVersion()); 596 | tarsAttr.put("", _ret); 597 | tarsAttr.encode(_sResponseBuffer); 598 | } 599 | else 600 | { 601 | tars::TarsOutputStream _os; 602 | _os.write(_ret, 0); 603 | _os.swap(_sResponseBuffer); 604 | } 605 | } 606 | return tars::TARSSERVERSUCCESS; 607 | 608 | } 609 | case 1: 610 | { 611 | tars::TarsInputStream _is; 612 | _is.setBuffer(_current->getRequestBuffer()); 613 | std::string sIn; 614 | std::string sOut; 615 | if (_current->getRequestVersion() == TUPVERSION) 616 | { 617 | UniAttribute tarsAttr; 618 | tarsAttr.setVersion(_current->getRequestVersion()); 619 | tarsAttr.decode(_current->getRequestBuffer()); 620 | tarsAttr.get("sIn", sIn); 621 | tarsAttr.getByDefault("sOut", sOut, sOut); 622 | } 623 | else 624 | { 625 | _is.read(sIn, 1, true); 626 | _is.read(sOut, 2, false); 627 | } 628 | tars::Int32 _ret = testStr(sIn,sOut, _current); 629 | if(_current->isResponse()) 630 | { 631 | if (_current->getRequestVersion() == TUPVERSION ) 632 | { 633 | UniAttribute tarsAttr; 634 | tarsAttr.setVersion(_current->getRequestVersion()); 635 | tarsAttr.put("", _ret); 636 | tarsAttr.put("sOut", sOut); 637 | tarsAttr.encode(_sResponseBuffer); 638 | } 639 | else 640 | { 641 | tars::TarsOutputStream _os; 642 | _os.write(_ret, 0); 643 | _os.write(sOut, 2); 644 | _os.swap(_sResponseBuffer); 645 | } 646 | } 647 | return tars::TARSSERVERSUCCESS; 648 | 649 | } 650 | } 651 | return tars::TARSSERVERNOFUNCERR; 652 | } 653 | }; 654 | 655 | 656 | } 657 | 658 | 659 | 660 | #endif 661 | -------------------------------------------------------------------------------- /PerfTestSoft/StressBenchmark/TarsStressClient/main.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Tars available. 3 | * 4 | * Copyright (C) 2016THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * 9 | * https://opensource.org/licenses/BSD-3-Clause 10 | * 11 | * Unless required by applicable law or agreed to in writing, software distributed 12 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 14 | * specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | #include "Stress.h" 18 | #include "servant/Communicator.h" 19 | #include "util/tc_thread_pool.h" 20 | #include 21 | 22 | using namespace std; 23 | using namespace Test; 24 | using namespace tars; 25 | 26 | class Test1 27 | { 28 | public: 29 | Test1(const string &sStr,const string &netthreads); 30 | Test1(){} 31 | ~Test1(); 32 | void dohandle(int excut_num,int size); 33 | private: 34 | Communicator _comm; 35 | StressPrx prx; 36 | }; 37 | 38 | Test1::Test1(const string &sStr, const string &netthreads) 39 | { 40 | _comm.setProperty("locator","tars.tarsregistry.QueryObj@tcp -h 192.168.1.100 -p 17890 -t 10000"); 41 | _comm.setProperty("stat", "tars.tarsstat.StatObj"); 42 | _comm.setProperty("netthread",netthreads); 43 | _comm.stringToProxy(sStr, prx); 44 | } 45 | 46 | Test1::~Test1() 47 | { 48 | 49 | } 50 | 51 | void Test1::dohandle(int excut_num,int size) 52 | { 53 | string s(size,'a'); 54 | 55 | tars::Int32 count = 0; 56 | unsigned long sum = 0; 57 | 58 | //time_t _iTime=TC_TimeProvider::getInstance()->getNowMs(); 59 | 60 | for(int i=0; itars_set_timeout(15000)->testStr(s,ret); 67 | if(ret.size() == s.size()) 68 | { 69 | ++sum; 70 | ++count; 71 | } 72 | 73 | if(count == excut_num) 74 | { 75 | //cout << "pthread id: " << pthread_self() << " | " << TC_TimeProvider::getInstance()->getNowMs() - _iTime << endl; 76 | count = 0; 77 | } 78 | } 79 | catch(TC_Exception &e) 80 | { 81 | cout << "pthread id: " << pthread_self() << "id: " << i << "exception: " << e.what() << endl; 82 | } 83 | catch(...) 84 | { 85 | cout << "pthread id: " << pthread_self() << "id: " << i << "unknown exception." << endl; 86 | } 87 | } 88 | cout << "succ:" << sum <(string(argv[1])); 105 | TC_ThreadPool tp; 106 | tp.init(threads); 107 | tp.start(); 108 | 109 | cout << "init tp succ" << endl; 110 | 111 | tars::Int32 times = TC_Common::strto(string(argv[2])); 112 | tars::Int32 size = TC_Common::strto(string(argv[3])); 113 | cout << "times:" << times << endl; 114 | 115 | time_t _iTime=TC_TimeProvider::getInstance()->getNowMs(); 116 | 117 | for(int i = 0; igetNowMs() - _iTime << endl; 125 | } 126 | catch(exception &e) 127 | { 128 | cout<getNowMs()-_time<getNowMs(); 54 | _num=0; 55 | } 56 | 57 | return 0; 58 | } 59 | -------------------------------------------------------------------------------- /PerfTestSoft/StressBenchmark/TarsStressServer/StressImp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Tars available. 3 | * 4 | * Copyright (C) 2016THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * 9 | * https://opensource.org/licenses/BSD-3-Clause 10 | * 11 | * Unless required by applicable law or agreed to in writing, software distributed 12 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 14 | * specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | #ifndef _StressImp_H_ 18 | #define _StressImp_H_ 19 | 20 | #include "servant/Application.h" 21 | #include "Stress.h" 22 | #include 23 | 24 | #define gettid() syscall(__NR_gettid) 25 | /** 26 | * 27 | * 28 | */ 29 | class StressImp : public Test::Stress 30 | { 31 | public: 32 | /** 33 | * 34 | */ 35 | virtual ~StressImp() {} 36 | 37 | /** 38 | * 39 | */ 40 | virtual void initialize(); 41 | 42 | /** 43 | * 44 | */ 45 | virtual void destroy(); 46 | 47 | /** 48 | * 49 | */ 50 | virtual int test(tars::TarsCurrentPtr current); 51 | 52 | 53 | tars::Int32 testStr(const std::string& sIn, std::string &sOut, tars::TarsCurrentPtr current); 54 | private: 55 | int _num; 56 | int64_t _time; 57 | }; 58 | ///////////////////////////////////////////////////// 59 | #endif 60 | -------------------------------------------------------------------------------- /PerfTestSoft/StressBenchmark/TarsStressServer/TarsStressServer.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Tars available. 3 | * 4 | * Copyright (C) 2016THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * 9 | * https://opensource.org/licenses/BSD-3-Clause 10 | * 11 | * Unless required by applicable law or agreed to in writing, software distributed 12 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 14 | * specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | #include "TarsStressServer.h" 18 | #include "StressImp.h" 19 | 20 | using namespace std; 21 | 22 | TarsStressServer g_app; 23 | 24 | ///////////////////////////////////////////////////////////////// 25 | void TarsStressServer::initialize() 26 | { 27 | //initialize application here: 28 | //... 29 | 30 | addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".StressObj"); 31 | } 32 | ///////////////////////////////////////////////////////////////// 33 | void TarsStressServer::destroyApp() 34 | { 35 | //destroy application here: 36 | //... 37 | } 38 | ///////////////////////////////////////////////////////////////// 39 | 40 | int main(int argc, char* argv[]) 41 | { 42 | try 43 | { 44 | g_app.main(argc, argv); 45 | g_app.waitForShutdown(); 46 | } 47 | catch (std::exception& e) 48 | { 49 | cerr << "std::exception:" << e.what() << std::endl; 50 | } 51 | catch (...) 52 | { 53 | cerr << "unknown exception." << std::endl; 54 | } 55 | return -1; 56 | } 57 | ///////////////////////////////////////////////////////////////// 58 | -------------------------------------------------------------------------------- /PerfTestSoft/StressBenchmark/TarsStressServer/TarsStressServer.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making Tars available. 3 | * 4 | * Copyright (C) 2016THL A29 Limited, a Tencent company. All rights reserved. 5 | * 6 | * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at 8 | * 9 | * https://opensource.org/licenses/BSD-3-Clause 10 | * 11 | * Unless required by applicable law or agreed to in writing, software distributed 12 | * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the 14 | * specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | #ifndef _TarsStressServer_H_ 18 | #define _TarsStressServer_H_ 19 | 20 | #include 21 | #include "servant/Application.h" 22 | 23 | using namespace tars; 24 | 25 | /** 26 | * 27 | **/ 28 | class TarsStressServer : public Application 29 | { 30 | public: 31 | /** 32 | * 33 | **/ 34 | virtual ~TarsStressServer() {}; 35 | 36 | /** 37 | * 38 | **/ 39 | virtual void initialize(); 40 | 41 | /** 42 | * 43 | **/ 44 | virtual void destroyApp(); 45 | 46 | protected: 47 | 48 | }; 49 | 50 | extern TarsStressServer g_app; 51 | 52 | //////////////////////////////////////////// 53 | #endif 54 | -------------------------------------------------------------------------------- /PerfTestSoft/StressBenchmark/TarsStressServer/makefile: -------------------------------------------------------------------------------- 1 | 2 | #----------------------------------------------------------------------- 3 | 4 | APP := Test 5 | TARGET := TarsStressServer 6 | CONFIG := 7 | STRIP_FLAG:= N 8 | TARS2CPP_FLAG:= 9 | 10 | INCLUDE += 11 | LIB += 12 | 13 | #----------------------------------------------------------------------- 14 | 15 | include /usr/local/tars/cpp/makefile/makefile.tars 16 | #----------------------------------------------------------------------- 17 | -------------------------------------------------------------------------------- /PerfTestSoft/introduction.md: -------------------------------------------------------------------------------- 1 | # Table of contents 2 | > * [1.Description](#main-chapter-1) 3 | > * [2.Framework Environment Setup](#main-chapter-2) 4 | > * [3.Server Side Test Software](#main-chapter-3) 5 | > * [4.Client Side Test Software](#main-chapter-4) 6 | > * [5.Note Well](#main-chapter-5) 7 | 8 | # 1. Description 9 | - This folder is used to store the software for Tars performance Test. 10 | - The test software consists of the client software and the server software. 11 | - The Tars framework should be set up successfully prior to run the performance test software. 12 | 13 | 14 | # 2. Tars Framework Environment Setup 15 | - In order to run the performance test, Tars framework is a must. 16 | - You can setup the framework via script or do it step-by-step. 17 | - Refer to the following link: 18 | - https://github.com/TarsCloud/Tars/tree/master/shellDeploy 19 | - https://github.com/TarsCloud/Tars#installation 20 | 21 | 22 | # 3. Server Side Test Software 23 | - For the server side, 24 | 25 | 26 | # 4. Client Side Test Software 27 | - For the client side, 28 | 29 | 30 | 31 | # 5. Note Well 32 | - More informations you should pay special attention to. 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # TARS - A Linux Foundation Project 4 | 5 | - [TARS Foundation Official Website](https://tarscloud.org/foundation/index) 6 | - [TARS Project Official Website](http://tarscloud.org/) 7 | - WeChat Offical Account: TarsCloud 8 | - QQ Group: 733605310, 579079160(Full), 669339903(Full) 9 | - Twitter: [@TarsCloud](https://twitter.com/TarsCloud) 10 | - [Mailing List](https://groups.google.com/g/tars-foundation-information) 11 | - [Contacts](https://tarscloud.org/about/contacts) 12 | 13 | ## What is TARS? 14 | 15 | TARS is a Linux Foundation project. It is a high-performance RPC framework based on name service and Tars protocol, also integrated administration platform, and implemented hosting-service via flexible schedule. 16 | 17 | Tars, aka TAF(Total Application Framework), has been used in Tencent since 2008. It supports C++, Java, Nodejs and PHP for now. This framework offers a set of solution for development, maintenance and testing, which making development, deployment and testing service efficiently. 18 | It integrated extensible protocol for encoding/decoding, high-performance RPC communication framework, name service, monitor, statistics and configuration. You can use it to develop your reliable distributed application based on microservice fast, and reach fully efficient service management. 19 | 20 | Nowadays it's used by hundreds of bussiness in Tencent, services that developed base on TAF run on 16 thousands of machines. 21 | 22 | See the detailed introduction [SUMMARY.md](https://tarscloud.github.io/TarsDocs_en/). 23 | 24 | ## Supported platforms 25 | For now it supports OS as below: 26 | 27 | - Linux 28 | - Mac(>=2.1.0 support) 29 | - Windows (>= Windows 7) 30 | 31 | ## Supported languages 32 | 33 | For now it supports following languages: 34 | 35 | - C++ 36 | - Java 37 | - Nodejs 38 | - PHP 39 | - Go 40 | 41 | ## Version Management 42 | 43 | Tars is composed of many modules, scattered in many warehouses, and the basic framework version and language version can develop independently. In view of this, from version 2.1.0, the Framework version tag is printed on the tarsframework warehouse, no longer reflected in the tars warehouse 44 | 45 | In addition, each component will have its own version. When there is a version dependency specification, each component will have its own version 46 | 47 | ## Installation 48 | 49 | 1. If you are new to Tars, please read documentation [installation](https://tarscloud.github.io/TarsDocs_en/installation). 50 | 2. First deploy, please read documentation [source](https://tarscloud.github.io/TarsDocs_en/installation/source.html). 51 | 3. Install by docker, detail information: [docker](https://tarscloud.github.io/TarsDocs_en/installation/docker.html)。 52 | 53 | ## Submodule 54 | 55 | Directory |Features 56 | ------------------|---------------- 57 | framework |Source code implementation of C++ language framework basic service 58 | cpp |C++ language framework rpc source code implementation 59 | java |java language framework rpc source code implementation 60 | go |go language framework rpc source code implementation 61 | nodejs |nodejs language framework rpc source code implementation 62 | php |php language framework rpc source code implementation 63 | tup |source code implementation of tup group protocol in each language 64 | web |manage tars web source implementation 65 | 66 | ## Developer's documentation 67 | 68 | See [docs](https://github.com/TarsCloud/TarsDocs_en). 69 | 70 | ## License 71 | 72 | The open-source protocol Tars used is BSD-3-Clause, see [LICENSE.md](https://github.com/TarsCloud/TarsDocs_en/blob/master/LICENSE). 73 | 74 | ## Chinese Version 75 | [Read Chinese Version](README.zh.md) 76 | 77 | -------------------------------------------------------------------------------- /README.zh.md: -------------------------------------------------------------------------------- 1 | [Click me switch to English version](README.md) 2 | 3 | # Readme.md 4 | 5 | # Tars 6 | 7 | - Twitter: [@TarsCloud](https://twitter.com/TarsCloud) 8 | - [Mailing List](https://groups.google.com/g/tars-foundation-information) 9 | - [官网](http://tarscloud.org/) 10 | - [新闻](https://tarscloud.org/feed/newsroom) 11 | - qq技术交流群群:733605310, 579079160(满), 669339903(满) 12 | - 微信公众号: TarsCloud 13 | - [更多联系方式请点击](https://tarscloud.org/about/contacts) 14 | 15 | ## 简介 16 | 17 | Tars这个名字取自于电影"星际穿越"中的机器人,它是基于名字服务使用Tars协议的高性能RPC开发框架,配套一体化的运营管理平台,并通过伸缩调度,实现运维半托管服务。 18 | 19 | Tars是腾讯从2008年到今天一直在使用的后台逻辑层的统一应用框架TAF(Total Application Framework),目前支持C++,Java,PHP,Nodejs,Go语言。该框架为用户提供了涉及到开发、运维、以及测试的一整套解决方案,帮助一个产品或者服务快速开发、部署、测试、上线。 它集可扩展协议编解码、高性能RPC通信框架、名字路由与发现、发布监控、日志统计、配置管理等于一体,通过它可以快速用微服务的方式构建自己的稳定可靠的分布式应用,并实现完整有效的服务治理。 20 | 21 | 目前该框架在腾讯内部,各大核心业务都在使用,颇受欢迎,基于该框架部署运行的服务节点规模达到上万个。 22 | 23 | Tars详细介绍参见 [目录](https://tarscloud.github.io/TarsDocs/SUMMARY.html)。 24 | 25 | ## 安装 26 | 27 | 1. 如果你是新手安装Tars, 请务必阅读部署的整体的说明 [installation](https://tarscloud.github.io/TarsDocs/installation) 28 | 2. 如果你是第一次部署, 建议采用源码部署熟悉系统 [source](https://tarscloud.github.io/TarsDocs/installation/source.html) 29 | 3. 如果你比较熟悉, 可以采用docker部署 [docker](https://tarscloud.github.io/TarsDocs/installation/docker.html) 30 | 31 | 32 | ### 支持平台 33 | 34 | 目前运行的操作系统平台如下: 35 | 36 | * Linux 37 | * Mac(>=2.1.0 support) 38 | 39 | ### 支持语言 40 | 41 | 目前支持的开发语言如下: 42 | 43 | * C++ 44 | * Java 45 | * Nodejs 46 | * PHP 47 | * Go 48 | 49 | ### 版本管理 50 | 51 | Tars由多种模块组成, 分散在多个仓库中, 并且基础框架版本和语言版本可以独立发展, 鉴于此, 从2.1.0版本开始, 框架的版本TAG打在TarsFramework仓库上, 不再体现在Tars这个仓库上. 52 | 53 | 另外各个组件会有自己独立的版本, 当有版本依赖说明时, 各组件会独立说明. 54 | 55 | 56 | ### License 57 | 58 | Tars的开源协议为BSD-3-Clause,详情参见 [LICENSE](https://github.com/TarsCloud/TarsDocs/blob/master/LICENSE)。 59 | 60 | ### 参与贡献 61 | 62 | 如果你有任何想法,别犹豫,立即提 Issues 或 Pull Requests,欢迎所有人参与到 TARS 的开源建设中。 63 | 提PR前请先确认签署了 [CLA](https://tarscloud.github.io/TarsDocs/cla.html) 哦。 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /tag.sh: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 2 | # Linux Foundation Projects 3 | # Link: https://www.linuxfoundation.org/projects/ 4 | # TARS Foundation Projects 5 | # Link: https://github.com/TarsCloud 6 | # All rights reserved. 7 | 8 | #!/bin/bash 9 | 10 | #update & merge code tools 11 | 12 | function show() 13 | { 14 | branch=$1 15 | 16 | echo "tars:"; git branch -a | grep "*"; 17 | cd framework; echo "framework:"; git branch -a | grep "*"; 18 | cd tarscpp; echo "tarscpp:"; git branch -a | grep "*"; 19 | cd servant/protocol; echo "protocol:"; git branch -a | grep "*"; 20 | cd ../../../.. 21 | } 22 | 23 | 24 | function update() 25 | { 26 | branch=$1 27 | 28 | git submodule update --remote --recursive 29 | 30 | cd framework; git checkout $branch; git pull --rebase; 31 | cd tarscpp; git checkout $branch; git pull --rebase; 32 | cd servant/protocol; git checkout $branch; git pull --rebase; 33 | cd ../../../.. 34 | } 35 | 36 | function merge() 37 | { 38 | version1=$1 39 | version2=$2 40 | 41 | cd framework; git checkout $version2; git pull $version2 --rebase; git checkout $version1; git merge $version2; 42 | cd tarscpp; git checkout $version2; git pull $version2 --rebase; git checkout $version1; git merge $version2; 43 | cd servant/protocol; git checkout $version2; git pull $version2 --rebase; git checkout $version1; git merge $version2; 44 | cd ../../../.. 45 | } 46 | 47 | function branch() 48 | { 49 | version1=$1 50 | cd framework/tarscpp/servant/protocol; git checkout $version1; 51 | cd ../..; git checkout $version1; 52 | cd ..; git checkout $version1; 53 | cd ..; git checkout $version1; 54 | } 55 | 56 | function commit() 57 | { 58 | version1=$1 59 | cd framework/tarscpp/servant/protocol; git checkout $version1; git commit -a -m "update merge"; 60 | cd ../..; git checkout $version1; git commit -a -m "update protocol"; 61 | cd ..; git checkout $version1; git commit -a -m "update tarscpp"; 62 | cd ..; git checkout $version1; git commit -a -m "update framework"; 63 | } 64 | 65 | function push() 66 | { 67 | version1=$1 68 | cd framework; git checkout $version1; git push origin $version1; 69 | cd tarscpp; git checkout $version1; git push origin $version1; 70 | cd servant/protocol; git checkout $version1; git push origin $version1; 71 | cd ../../../..;git checkout $version1; git push origin $version1; 72 | } 73 | 74 | version=$2 75 | case $1 in 76 | "show") 77 | show 78 | ;; 79 | "branch") 80 | branch $2 81 | show 82 | ;; 83 | "update") 84 | update $2 85 | ;; 86 | "commit") 87 | commit $2 88 | ;; 89 | "push") 90 | push $2 91 | ;; 92 | "merge-master") 93 | merge master release/2.4 94 | ;; 95 | "merge-release") 96 | merge release/2.4 master 97 | ;; 98 | "all") 99 | show 100 | update release/2.4 101 | merge-release 102 | commit release/2.4 103 | push release/2.4 104 | update master 105 | merge-master 106 | commit master 107 | push master 108 | ;; 109 | *) 110 | echo "$0 show, show all branch" 111 | echo "$0 branch [branch], checkout to branch" 112 | echo "$0 update [branch], update branch to new" 113 | echo "$0 commit [branch], commit branch" 114 | echo "$0 push [branch], push branch" 115 | echo "$0 merge-master], checkout master and merge release to master" 116 | echo "$0 merge-release], checkout relase and merge master to release" 117 | echo "$0 all, do all" 118 | ;; 119 | esac 120 | 121 | -------------------------------------------------------------------------------- /tars-deploy-framework.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if (( $# < 2 )) 4 | then 5 | echo $# 6 | echo "$0 tag push(false/true)" 7 | exit 1 8 | fi 9 | 10 | tag=$1 11 | push=$2 12 | 13 | if [ "$push" == "true" ]; then 14 | push="true" 15 | else 16 | push="false" 17 | fi 18 | 19 | # tarsTag=$(git describe --tags $(git rev-list --tags --max-count=1) --abbrev=0 --always) 20 | # cd framework && frameworkTag=$(git describe --tags $(git rev-list --tags --max-count=1) --abbrev=0 --always) && cd .. 21 | # cd web && webTag=$(git describe --tags $(git rev-list --tags --max-count=1) --abbrev=0 --always) && cd .. 22 | 23 | tarsTag=$tag 24 | cd framework && frameworkTag=$(git reflog HEAD | grep 'checkout:' | head -1 | awk '{print $NF}') && cd .. 25 | cd web && webTag=$(git reflog HEAD | grep 'checkout:' | head -1 | awk '{print $NF}') && cd .. 26 | 27 | echo "starting tars:${tarsTag} framework:$frameworkTag web:$webTag deploy" 28 | 29 | cd docker/framework 30 | ./build-docker.sh $frameworkTag $webTag ${tarsTag} ${push} 31 | -------------------------------------------------------------------------------- /tars-deploy-tars.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if (( $# < 2 )) 4 | then 5 | echo $# 6 | echo "$0 tag push(false/true)" 7 | exit 1 8 | fi 9 | 10 | tag=$1 11 | push=$2 12 | 13 | if [ "$push" == "true" ]; then 14 | push="true" 15 | else 16 | push="false" 17 | fi 18 | 19 | # tarsTag=$(git describe --tags $(git rev-list --tags --max-count=1) --abbrev=0 --always) 20 | # cd framework && frameworkTag=$(git describe --tags $(git rev-list --tags --max-count=1) --abbrev=0 --always) && cd .. 21 | # cd web && webTag=$(git describe --tags $(git rev-list --tags --max-count=1) --abbrev=0 --always) && cd .. 22 | 23 | tarsTag=$tag 24 | cd framework && frameworkTag=$(git reflog HEAD | grep 'checkout:' | head -1 | awk '{print $NF}') && cd .. 25 | cd web && webTag=$(git reflog HEAD | grep 'checkout:' | head -1 | awk '{print $NF}') && cd .. 26 | 27 | echo "starting tars:${tarsTag} framework:$frameworkTag web:$webTag deploy" 28 | 29 | cd docker/tars 30 | ./build-docker.sh $frameworkTag $webTag ${tarsTag} ${push} 31 | -------------------------------------------------------------------------------- /tars-latest-deploy-framework.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if (( $# < 1 )) 4 | then 5 | echo $# 6 | echo "$0 push(false/true)" 7 | exit 1 8 | fi 9 | 10 | push=$1 11 | 12 | if [ "$push" == "true" ]; then 13 | push="true" 14 | else 15 | push="false" 16 | fi 17 | 18 | cd docker/framework 19 | ./build-docker.sh master master latest ${push} 20 | -------------------------------------------------------------------------------- /tars-latest-deploy-tars.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if (( $# < 1 )) 4 | then 5 | echo $# 6 | echo "$0 push(false/true)" 7 | exit 1 8 | fi 9 | 10 | push=$1 11 | 12 | if [ "$push" == "true" ]; then 13 | push="true" 14 | else 15 | push="false" 16 | fi 17 | 18 | cd docker/tars 19 | ./build-docker.sh master master latest ${push} 20 | --------------------------------------------------------------------------------