├── .github
└── workflows
│ ├── ccpp-linux.yml
│ ├── ccpp-mac.yml
│ ├── ccpp-win.yml
│ └── gitee-sync.yml
├── .gitignore
├── .gitmodules
├── CMakeLists.txt
├── Changelist-2.x.md
├── Changelist-3.x.md
├── Contributing.md
├── LICENSE
├── README.md
├── README.zh.md
├── cmake
├── BuildTarsCpp.cmake
├── Common.cmake
├── GenVersion.cmake
├── ParseAsm.cmake
└── Thirdparty.cmake
├── cross-compiler.cmake
├── docs-en
└── README.md
├── docs
└── README.md
├── examples
├── AuthDemo
│ ├── CMakeLists.txt
│ ├── Client
│ │ ├── CMakeLists.txt
│ │ ├── config.conf
│ │ └── main.cpp
│ └── Server
│ │ ├── CMakeLists.txt
│ │ ├── Hello.tars
│ │ ├── HelloImp.cpp
│ │ ├── HelloImp.h
│ │ ├── HelloServer.cpp
│ │ ├── HelloServer.h
│ │ └── config.conf
├── CMakeLists.txt
├── ClientDemo
│ ├── CMakeLists.txt
│ └── main.cpp
├── CoroutineDemo
│ ├── AServer
│ │ ├── AServant.tars
│ │ ├── AServantImp.cpp
│ │ ├── AServantImp.h
│ │ ├── AServer.cpp
│ │ ├── AServer.h
│ │ ├── CMakeLists.txt
│ │ └── config.conf
│ ├── BServer
│ │ ├── BServant.tars
│ │ ├── BServantImp.cpp
│ │ ├── BServantImp.h
│ │ ├── BServer.cpp
│ │ ├── BServer.h
│ │ ├── CMakeLists.txt
│ │ └── config.conf
│ ├── CMakeLists.txt
│ ├── README.md
│ ├── client
│ │ ├── CMakeLists.txt
│ │ └── main.cpp
│ ├── testCoro
│ │ ├── CMakeLists.txt
│ │ └── main.cpp
│ └── testParallelCoro
│ │ ├── CMakeLists.txt
│ │ └── main.cpp
├── CustomDemo
│ ├── CMakeLists.txt
│ ├── CustomClient
│ │ ├── CMakeLists.txt
│ │ └── main.cpp
│ ├── CustomServer
│ │ ├── CMakeLists.txt
│ │ ├── CustomServantImp.cpp
│ │ ├── CustomServantImp.h
│ │ ├── CustomServer.cpp
│ │ ├── CustomServer.h
│ │ └── config.conf
│ └── README.md
├── GrpcDemo
│ ├── CMakeLists.txt
│ ├── GrpcClient
│ │ ├── CMakeLists.txt
│ │ ├── helloworld.proto
│ │ └── main.cpp
│ └── GrpcServer
│ │ ├── CMakeLists.txt
│ │ ├── GrpcImp.cpp
│ │ ├── GrpcImp.h
│ │ ├── GrpcServer.cpp
│ │ ├── GrpcServer.h
│ │ ├── config.conf
│ │ └── helloworld.proto
├── HttpDemo
│ ├── CMakeLists.txt
│ ├── Http2Client
│ │ ├── CMakeLists.txt
│ │ └── main.cpp
│ ├── Http2Server
│ │ ├── CMakeLists.txt
│ │ ├── Http2Imp.cpp
│ │ ├── Http2Imp.h
│ │ ├── HttpServer.cpp
│ │ ├── HttpServer.h
│ │ └── config.conf
│ ├── HttpClient
│ │ ├── CMakeLists.txt
│ │ └── main.cpp
│ └── HttpServer
│ │ ├── CMakeLists.txt
│ │ ├── HttpImp.cpp
│ │ ├── HttpImp.h
│ │ ├── HttpServer.cpp
│ │ ├── HttpServer.h
│ │ └── config.conf
├── PromiseDemo
│ ├── AServer
│ │ ├── AServant.tars
│ │ ├── AServantImp.cpp
│ │ ├── AServantImp.h
│ │ ├── AServer.cpp
│ │ ├── AServer.h
│ │ ├── BServant.tars
│ │ ├── CServant.tars
│ │ └── makefile
│ ├── BServer
│ │ ├── BServant.tars
│ │ ├── BServantImp.cpp
│ │ ├── BServantImp.h
│ │ ├── BServer.cpp
│ │ ├── BServer.h
│ │ └── makefile
│ ├── CServer
│ │ ├── CServant.tars
│ │ ├── CServantImp.cpp
│ │ ├── CServantImp.h
│ │ ├── CServer.cpp
│ │ ├── CServer.h
│ │ └── makefile
│ ├── Client
│ │ ├── main.cpp
│ │ └── makefile
│ └── README.md
├── PushCallbackDemo
│ ├── CMakeLists.txt
│ ├── Client
│ │ ├── CMakeLists.txt
│ │ ├── config.conf
│ │ └── main.cpp
│ └── Server
│ │ ├── CMakeLists.txt
│ │ ├── Hello.tars
│ │ ├── HelloImp.cpp
│ │ ├── HelloImp.h
│ │ ├── HelloServer.cpp
│ │ ├── HelloServer.h
│ │ ├── Push.tars
│ │ ├── PushThread.cpp
│ │ ├── PushThread.h
│ │ └── config.conf
├── PushDemo
│ ├── CMakeLists.txt
│ ├── PushClient
│ │ ├── CMakeLists.txt
│ │ ├── TestRecvThread.cpp
│ │ ├── TestRecvThread.h
│ │ └── main.cpp
│ ├── PushServer
│ │ ├── CMakeLists.txt
│ │ ├── TestPushServantImp.cpp
│ │ ├── TestPushServantImp.h
│ │ ├── TestPushServer.cpp
│ │ ├── TestPushServer.h
│ │ ├── TestPushThread.cpp
│ │ ├── TestPushThread.h
│ │ └── config.conf
│ └── README.md
├── QuickStartDemo
│ ├── CMakeLists.txt
│ ├── HelloServer
│ │ ├── CMakeLists.txt
│ │ ├── Client
│ │ │ ├── CMakeLists.txt
│ │ │ └── main.cpp
│ │ └── Server
│ │ │ ├── CMakeLists.txt
│ │ │ ├── Hello.tars
│ │ │ ├── HelloImp.cpp
│ │ │ ├── HelloImp.h
│ │ │ ├── HelloServer.cpp
│ │ │ ├── HelloServer.h
│ │ │ ├── config-1.conf
│ │ │ ├── config-2.conf
│ │ │ └── config.conf
│ ├── ProxyServer
│ │ ├── CMakeLists.txt
│ │ ├── Client
│ │ │ ├── CMakeLists.txt
│ │ │ └── main.cpp
│ │ └── Server
│ │ │ ├── CMakeLists.txt
│ │ │ ├── Proxy.tars
│ │ │ ├── ProxyImp.cpp
│ │ │ ├── ProxyImp.h
│ │ │ ├── ProxyServer.cpp
│ │ │ ├── ProxyServer.h
│ │ │ └── config.conf
│ └── README.md
├── README.md
├── SSLDemo
│ ├── CMakeLists.txt
│ ├── Client
│ │ ├── CMakeLists.txt
│ │ ├── config.conf
│ │ └── main.cpp
│ ├── Server
│ │ ├── CMakeLists.txt
│ │ ├── SSLImp.cpp
│ │ ├── SSLImp.h
│ │ ├── SSLServer.cpp
│ │ ├── SSLServer.h
│ │ ├── config.conf
│ │ └── ssl.tars
│ └── certs
│ │ ├── ca.crt
│ │ ├── ca.key
│ │ ├── ca.srl
│ │ ├── client.crt
│ │ ├── client.csr
│ │ ├── client.key
│ │ ├── client1.crt
│ │ ├── client1.csr
│ │ ├── client1.key
│ │ ├── create.sh
│ │ ├── server.crt
│ │ ├── server.csr
│ │ ├── server.key
│ │ ├── server1.crt
│ │ ├── server1.csr
│ │ └── server1.key
├── StressDemo
│ ├── CMakeLists.txt
│ ├── README.md
│ ├── TarsStressClient
│ │ ├── CMakeLists.txt
│ │ ├── main.cpp
│ │ └── teststress.sh
│ └── TarsStressServer
│ │ ├── CMakeLists.txt
│ │ ├── Stress.tars
│ │ ├── StressImp.cpp
│ │ ├── StressImp.h
│ │ ├── TarsStressServer.cpp
│ │ └── TarsStressServer.h
├── UdpDemo
│ ├── CMakeLists.txt
│ ├── Client
│ │ ├── CMakeLists.txt
│ │ ├── config.conf
│ │ └── main.cpp
│ └── Server
│ │ ├── CMakeLists.txt
│ │ ├── Hello.tars
│ │ ├── HelloImp.cpp
│ │ ├── HelloImp.h
│ │ ├── HelloServer.cpp
│ │ ├── HelloServer.h
│ │ └── config.conf
├── UtilDemo
│ ├── CMakeLists.txt
│ ├── demo-server
│ │ ├── CMakeLists.txt
│ │ └── demo_server.cpp
│ └── demo-util
│ │ ├── CMakeLists.txt
│ │ ├── main.cpp
│ │ ├── test_tc_encoder.cpp
│ │ ├── test_tc_file.cpp
│ │ └── test_tc_http.cpp
└── scripts
│ ├── run-auth.bat
│ ├── run-auth.sh
│ ├── run-co.bat
│ ├── run-co.sh
│ ├── run-custom.bat
│ ├── run-custom.sh
│ ├── run-http.bat
│ ├── run-http.sh
│ ├── run-http2.bat
│ ├── run-http2.sh
│ ├── run-kill.bat
│ ├── run-kill.sh
│ ├── run-push-callback.bat
│ ├── run-push-callback.sh
│ ├── run-push.bat
│ ├── run-push.sh
│ ├── run-quick-start.bat
│ ├── run-quick-start.sh
│ ├── run-ssl.bat
│ ├── run-ssl.sh
│ ├── run-udp.bat
│ └── run-udp.sh
├── mock
├── CMakeLists.txt
├── ConfigImp.cpp
├── ConfigImp.h
├── DbHandle.cpp
├── DbHandle.h
├── FrameworkServer.cpp
├── FrameworkServer.h
├── LogImp.cpp
├── LogImp.h
├── QueryImp.cpp
├── QueryImp.h
├── StatImp.cpp
├── StatImp.h
├── TarsMockUtil.cpp
├── TarsMockUtil.h
└── framework.h
├── servant
├── CMakeLists.txt
├── README.md
├── README.zh.md
├── jmem
│ ├── jmem_hashmap.h
│ ├── jmem_hashmap_compact.h
│ ├── jmem_multi_hashmap.h
│ ├── jmem_policy.h
│ ├── jmem_queue.h
│ └── jmem_rbtree.h
├── libservant
│ ├── AdapterProxy.cpp
│ ├── AdminServant.cpp
│ ├── AppCache.cpp
│ ├── AppProtocol.cpp
│ ├── Application.cpp
│ ├── AsyncProcThread.cpp
│ ├── AuthLogic.cpp
│ ├── BaseNotify.cpp
│ ├── CMakeLists.txt
│ ├── Communicator.cpp
│ ├── CommunicatorEpoll.cpp
│ ├── Current.cpp
│ ├── EndpointInfo.cpp
│ ├── EndpointManager.cpp
│ ├── Global.cpp
│ ├── KeepAliveNodeF.cpp
│ ├── Message.cpp
│ ├── NotifyObserver.cpp
│ ├── ObjectProxy.cpp
│ ├── PropertyReport.cpp
│ ├── RemoteConfig.cpp
│ ├── RemoteLogger.cpp
│ ├── RemoteNotify.cpp
│ ├── Servant.cpp
│ ├── ServantHandle.cpp
│ ├── ServantHelper.cpp
│ ├── ServantProxy.cpp
│ ├── ServantProxyFactory.cpp
│ └── StatReport.cpp
├── makefile
│ ├── makefile.tars
│ └── tars-tools.cmake.in
├── promise
│ ├── bind.h
│ ├── bind_internal.h
│ ├── callback.h
│ ├── exception.h
│ ├── function.h
│ ├── promise.h
│ ├── template_helper.h
│ ├── type_list.h
│ └── when_all.h
├── script
│ ├── busybox.exe
│ ├── cmake_demo
│ │ ├── CMakeLists.txt
│ │ └── src
│ │ │ ├── CMakeLists.txt
│ │ │ ├── DemoServant.tars
│ │ │ ├── DemoServantImp.cpp
│ │ │ ├── DemoServantImp.h
│ │ │ ├── DemoServer.cpp
│ │ │ └── DemoServer.h
│ ├── cmake_http_demo
│ │ ├── CMakeLists.txt
│ │ └── src
│ │ │ ├── CMakeLists.txt
│ │ │ ├── DemoServantImp.cpp
│ │ │ ├── DemoServantImp.h
│ │ │ ├── DemoServer.cpp
│ │ │ └── DemoServer.h
│ ├── cmake_http_server.bat
│ ├── cmake_http_server.sh
│ ├── cmake_tars_server.bat
│ ├── cmake_tars_server.sh
│ ├── create_http_server.sh
│ ├── create_tars_server.sh
│ ├── demo
│ │ ├── DemoServant.tars
│ │ ├── DemoServantImp.cpp
│ │ ├── DemoServantImp.h
│ │ ├── DemoServer.cpp
│ │ ├── DemoServer.h
│ │ └── makefile
│ └── http_demo
│ │ ├── DemoServantImp.cpp
│ │ ├── DemoServantImp.h
│ │ ├── DemoServer.cpp
│ │ ├── DemoServer.h
│ │ └── makefile
├── servant
│ ├── AdapterProxy.h
│ ├── AdminServant.h
│ ├── AppCache.h
│ ├── AppProtocol.h
│ ├── Application.h
│ ├── AsyncProcThread.h
│ ├── AuthLogic.h
│ ├── BaseNotify.h
│ ├── Communicator.h
│ ├── CommunicatorEpoll.h
│ ├── CommunicatorFactory.h
│ ├── Cookie.h
│ ├── Current.h
│ ├── EndpointInfo.h
│ ├── EndpointManager.h
│ ├── Global.h
│ ├── KeepAliveNodeF.h
│ ├── Message.h
│ ├── NotifyObserver.h
│ ├── ObjectProxy.h
│ ├── ObjectProxyFactory.h
│ ├── PropertyReport.h
│ ├── RemoteConfig.h
│ ├── RemoteLogger.h
│ ├── RemoteNotify.h
│ ├── ReqTime.h
│ ├── Servant.h
│ ├── ServantHandle.h
│ ├── ServantHelper.h
│ ├── ServantProxy.h
│ ├── ServantProxyFactory.h
│ ├── StatReport.h
│ └── TarsLogger.h
└── tup
│ ├── CMakeLists.txt
│ ├── RequestF.tars
│ ├── Tars.h
│ ├── TarsDisplayer.h
│ ├── TarsJson.h
│ ├── TarsType.h
│ ├── TarsXml.h
│ └── tup.h
├── tools
├── CMakeLists.txt
├── README.md
├── README.zh.md
├── pb2tarscpp
│ ├── CMakeLists.txt
│ ├── CppGenCallback.cpp
│ ├── CppGenCallback.h
│ ├── CppGenProxy.cpp
│ ├── CppGenProxy.h
│ ├── CppGenServant.cpp
│ ├── CppGenServant.h
│ ├── CppPbUtils.cpp
│ ├── CppPbUtils.h
│ ├── CppPlugin.cpp
│ └── CppPlugin.h
├── tars2android
│ ├── CMakeLists.txt
│ ├── interface_analysis.cpp
│ ├── interface_analysis.h
│ ├── main.cpp
│ ├── tars2android.cpp
│ ├── tars2android.h
│ ├── tars_filter.cpp
│ └── tars_filter.h
├── tars2c
│ ├── CMakeLists.txt
│ ├── main.cpp
│ ├── tars2c.cpp
│ └── tars2c.h
├── tars2case
│ ├── CMakeLists.txt
│ ├── main.cpp
│ ├── tars2case.cpp
│ └── tars2case.h
├── tars2cpp
│ ├── CMakeLists.txt
│ ├── main.cpp
│ ├── tars2cpp.cpp
│ └── tars2cpp.h
├── tars2cs
│ ├── CMakeLists.txt
│ ├── main.cpp
│ ├── tars2cs.cpp
│ └── tars2cs.h
├── tars2node
│ ├── CMakeLists.txt
│ ├── code_generator.cpp
│ ├── code_generator.h
│ ├── file_util.cpp
│ ├── gen_js.cpp
│ ├── gen_js_dts.cpp
│ ├── gen_proxy.cpp
│ ├── gen_proxy_dts.cpp
│ ├── gen_proxy_ts.cpp
│ ├── gen_server.cpp
│ ├── gen_server_dts.cpp
│ ├── gen_server_imp.cpp
│ ├── gen_server_ts.cpp
│ ├── gen_server_ts_imp.cpp
│ ├── gen_ts.cpp
│ ├── idl_scan.cpp
│ ├── idl_util.cpp
│ └── main.cpp
├── tars2oc
│ ├── CMakeLists.txt
│ ├── main.cpp
│ ├── tars2oc.cpp
│ └── tars2oc.h
├── tars2php
│ ├── CMakeLists.txt
│ ├── main.cpp
│ ├── tars2php.cpp
│ └── tars2php.h
├── tars2python
│ ├── CMakeLists.txt
│ ├── main.cpp
│ ├── tars2python.cpp
│ └── tars2python.h
├── tarsgrammar
│ ├── CMakeLists.txt
│ ├── tars.l
│ ├── tars.tab.cpp
│ └── tars.y
├── tarsmerge
│ ├── CMakeLists.txt
│ └── main.cpp
└── tarsparse
│ ├── CMakeLists.txt
│ ├── element.cpp
│ ├── element.h
│ ├── parse.cpp
│ ├── parse.h
│ ├── tars.lex.cpp
│ ├── tars.tab.cpp
│ └── tars.tab.hpp
├── unit-test
├── CMakeLists.txt
├── certs.h
├── certs
│ ├── ca.crt
│ ├── ca.key
│ ├── ca.srl
│ ├── client.crt
│ ├── client.csr
│ ├── client.key
│ ├── client1.crt
│ ├── client1.csr
│ ├── client1.key
│ ├── create.sh
│ ├── server.crt
│ ├── server.csr
│ ├── server.key
│ ├── server1.crt
│ ├── server1.csr
│ └── server1.key
├── hello_test.cpp
├── hello_test.h
├── main.cpp
├── rpc
│ ├── test_admin.cpp
│ ├── test_async_rpc.cpp
│ ├── test_auth.cpp
│ ├── test_close.cpp
│ ├── test_communicator.cpp
│ ├── test_custom.cpp
│ ├── test_dyeing.cpp
│ ├── test_http.cpp
│ ├── test_proxy_timeout.cpp
│ ├── test_prx_update.cpp
│ ├── test_push.cpp
│ ├── test_registry.cpp
│ ├── test_rpc.cpp
│ ├── test_ssl.cpp
│ ├── test_stat.cpp
│ ├── test_trans.cpp
│ ├── test_udp.cpp
│ ├── test_win_server.cpp
│ ├── test_wup.cpp
│ └── test_wup_trans.cpp
├── server
│ ├── CustomImp.cpp
│ ├── CustomImp.h
│ ├── Hello.tars
│ ├── HelloImp.cpp
│ ├── HelloImp.h
│ ├── HelloServer.cpp
│ ├── HelloServer.h
│ ├── HttpImp.cpp
│ ├── HttpImp.h
│ ├── Push.tars
│ ├── PushImp.cpp
│ ├── PushImp.h
│ ├── PushThread.cpp
│ ├── PushThread.h
│ ├── RpcServer.cpp
│ ├── RpcServer.h
│ ├── TranImp.cpp
│ ├── TranImp.h
│ ├── WinServer.cpp
│ ├── WinServer.h
│ ├── client.conf
│ ├── hello.conf
│ ├── rpc1.conf
│ ├── rpc2.conf
│ ├── rpc3.conf
│ └── windows.conf
└── util
│ ├── test_server.h
│ ├── test_tc_cas.cpp
│ ├── test_tc_clientsocket.cpp
│ ├── test_tc_config.cpp
│ ├── test_tc_coroutine.cpp
│ ├── test_tc_docker.cpp
│ ├── test_tc_encoder.cpp
│ ├── test_tc_endpoint.cpp
│ ├── test_tc_epoller.cpp
│ ├── test_tc_epoller_server.cpp
│ ├── test_tc_file.cpp
│ ├── test_tc_http.cpp
│ ├── test_tc_http_async.cpp
│ ├── test_tc_json.cpp
│ ├── test_tc_logger.cpp
│ ├── test_tc_mysql.cpp
│ ├── test_tc_network_buffer.cpp
│ ├── test_tc_option.cpp
│ ├── test_tc_port.cpp
│ ├── test_tc_serialport.cpp
│ ├── test_tc_socket.cpp
│ ├── test_tc_thread_pool.cpp
│ ├── test_tc_timeout_queue_map.cpp
│ └── test_tc_timer.cpp
└── util
├── CMakeLists.txt
├── README.md
├── include
├── CMakeLists.txt
└── util
│ ├── sys
│ └── epoll.h
│ ├── tc_autoptr.h
│ ├── tc_base64.h
│ ├── tc_bitmap.h
│ ├── tc_cas_queue.h
│ ├── tc_cgi.h
│ ├── tc_clientsocket.h
│ ├── tc_common.h
│ ├── tc_config.h
│ ├── tc_consistent_hash.h
│ ├── tc_consistent_hash_new.h
│ ├── tc_coroutine.h
│ ├── tc_coroutine_mutex.h
│ ├── tc_coroutine_queue.h
│ ├── tc_cron.h
│ ├── tc_custom_protocol.h
│ ├── tc_des.h
│ ├── tc_docker.h
│ ├── tc_dyn_object.h
│ ├── tc_encoder.h
│ ├── tc_epoll_server.h
│ ├── tc_epoller.h
│ ├── tc_ex.h
│ ├── tc_fcontext.h
│ ├── tc_fifo.h
│ ├── tc_file.h
│ ├── tc_file_mutex.h
│ ├── tc_grpc.h
│ ├── tc_gzip.h
│ ├── tc_hash_fun.h
│ ├── tc_hashmap.h
│ ├── tc_hashmap_compact.h
│ ├── tc_http.h
│ ├── tc_http2.h
│ ├── tc_http_async.h
│ ├── tc_json.h
│ ├── tc_lock.h
│ ├── tc_logger.h
│ ├── tc_loop_queue.h
│ ├── tc_malloc_chunk.h
│ ├── tc_md5.h
│ ├── tc_mem_chunk.h
│ ├── tc_mem_queue.h
│ ├── tc_mem_vector.h
│ ├── tc_mmap.h
│ ├── tc_monitor.h
│ ├── tc_multi_hashmap.h
│ ├── tc_mysql.h
│ ├── tc_network_buffer.h
│ ├── tc_openssl.h
│ ├── tc_option.h
│ ├── tc_pack.h
│ ├── tc_parsepara.h
│ ├── tc_platform.h
│ ├── tc_port.h
│ ├── tc_progress_timer.h
│ ├── tc_proxy_info.h
│ ├── tc_rbtree.h
│ ├── tc_readers_writer_data.h
│ ├── tc_reflection.h
│ ├── tc_sem_mutex.h
│ ├── tc_serialport.h
│ ├── tc_sha.h
│ ├── tc_shm.h
│ ├── tc_singleton.h
│ ├── tc_socket.h
│ ├── tc_socket_async.h
│ ├── tc_spin_lock.h
│ ├── tc_split.h
│ ├── tc_squeue.h
│ ├── tc_strptime.h
│ ├── tc_tea.h
│ ├── tc_thread.h
│ ├── tc_thread_cond.h
│ ├── tc_thread_mutex.h
│ ├── tc_thread_pool.h
│ ├── tc_thread_queue.h
│ ├── tc_thread_rwlock.h
│ ├── tc_timeout_queue.h
│ ├── tc_timeout_queue_map.h
│ ├── tc_timeout_queue_new.h
│ ├── tc_timeout_queue_noid.h
│ ├── tc_timeprovider.h
│ ├── tc_timer.h
│ ├── tc_transceiver.h
│ ├── tc_uuid_generator.h
│ └── tc_xml.h
└── src
├── CMakeLists.txt
├── asm
├── Jamfile.v2
├── jump_arm64_aapcs_elf_gas.S
├── jump_arm64_aapcs_macho_gas.S
├── jump_arm_aapcs_elf_gas.S
├── jump_arm_aapcs_macho_gas.S
├── jump_arm_aapcs_pe_armasm.asm
├── jump_combined_sysv_macho_gas.S
├── jump_i386_ms_pe_gas.asm
├── jump_i386_ms_pe_masm.asm
├── jump_i386_sysv_elf_gas.S
├── jump_i386_sysv_macho_gas.S
├── jump_i386_x86_64_sysv_macho_gas.S
├── jump_mips32_o32_elf_gas.S
├── jump_ppc32_ppc64_sysv_macho_gas.S
├── jump_ppc32_sysv_elf_gas.S
├── jump_ppc32_sysv_macho_gas.S
├── jump_ppc32_sysv_xcoff_gas.S
├── jump_ppc64_sysv_elf_gas.S
├── jump_ppc64_sysv_macho_gas.S
├── jump_ppc64_sysv_xcoff_gas.S
├── jump_x86_64_ms_pe_gas.asm
├── jump_x86_64_ms_pe_masm.asm
├── jump_x86_64_sysv_elf_gas.S
├── jump_x86_64_sysv_macho_gas.S
├── make_arm64_aapcs_elf_gas.S
├── make_arm64_aapcs_macho_gas.S
├── make_arm_aapcs_elf_gas.S
├── make_arm_aapcs_macho_gas.S
├── make_arm_aapcs_pe_armasm.asm
├── make_combined_sysv_macho_gas.S
├── make_i386_ms_pe_gas.asm
├── make_i386_ms_pe_masm.asm
├── make_i386_sysv_elf_gas.S
├── make_i386_sysv_macho_gas.S
├── make_i386_x86_64_sysv_macho_gas.S
├── make_mips32_o32_elf_gas.S
├── make_ppc32_ppc64_sysv_macho_gas.S
├── make_ppc32_sysv_elf_gas.S
├── make_ppc32_sysv_macho_gas.S
├── make_ppc32_sysv_xcoff_gas.S
├── make_ppc64_sysv_elf_gas.S
├── make_ppc64_sysv_macho_gas.S
├── make_ppc64_sysv_xcoff_gas.S
├── make_x86_64_ms_pe_gas.asm
├── make_x86_64_ms_pe_masm.asm
├── make_x86_64_sysv_elf_gas.S
├── make_x86_64_sysv_macho_gas.S
├── ontop_arm64_aapcs_elf_gas.S
├── ontop_arm64_aapcs_macho_gas.S
├── ontop_arm_aapcs_elf_gas.S
├── ontop_arm_aapcs_macho_gas.S
├── ontop_arm_aapcs_pe_armasm.asm
├── ontop_combined_sysv_macho_gas.S
├── ontop_i386_ms_pe_gas.asm
├── ontop_i386_ms_pe_masm.asm
├── ontop_i386_sysv_elf_gas.S
├── ontop_i386_sysv_macho_gas.S
├── ontop_i386_x86_64_sysv_macho_gas.S
├── ontop_mips32_o32_elf_gas.S
├── ontop_ppc32_ppc64_sysv_macho_gas.S
├── ontop_ppc32_sysv_elf_gas.S
├── ontop_ppc32_sysv_macho_gas.S
├── ontop_ppc32_sysv_xcoff_gas.S
├── ontop_ppc64_sysv_elf_gas.S
├── ontop_ppc64_sysv_macho_gas.S
├── ontop_ppc64_sysv_xcoff_gas.S
├── ontop_x86_64_ms_pe_gas.asm
├── ontop_x86_64_ms_pe_masm.asm
├── ontop_x86_64_sysv_elf_gas.S
└── ontop_x86_64_sysv_macho_gas.S
├── epoll_windows
└── src
│ ├── epoll.cpp
│ ├── msafd.h
│ └── ntapi.h
├── tc_base64.cpp
├── tc_bitmap.cpp
├── tc_cgi.cpp
├── tc_clientsocket.cpp
├── tc_common.cpp
├── tc_config.cpp
├── tc_consistent_hash_new.cpp
├── tc_coroutine.cpp
├── tc_coroutine_mutex.cpp
├── tc_cron.cpp
├── tc_des.cpp
├── tc_docker.cpp
├── tc_dyn_object.cpp
├── tc_encoder.cpp
├── tc_epoll_server.cpp
├── tc_epoller.cpp
├── tc_ex.cpp
├── tc_fifo.cpp
├── tc_file.cpp
├── tc_file_mutex.cpp
├── tc_grpc.cpp
├── tc_gzip.cpp
├── tc_hashmap.cpp
├── tc_hashmap_compact.cpp
├── tc_http.cpp
├── tc_http2.cpp
├── tc_http_async.cpp
├── tc_json.cpp
├── tc_logger.cpp
├── tc_malloc_chunk.cpp
├── tc_md5.cpp
├── tc_mem_chunk.cpp
├── tc_mem_queue.cpp
├── tc_mmap.cpp
├── tc_multi_hashmap.cpp
├── tc_mysql.cpp
├── tc_network_buffer.cpp
├── tc_openssl.cpp
├── tc_option.cpp
├── tc_pack.cpp
├── tc_parsepara.cpp
├── tc_port.cpp
├── tc_progress_timer.cpp
├── tc_proxy_info.cpp
├── tc_rbtree.cpp
├── tc_sem_mutex.cpp
├── tc_serialport.cpp
├── tc_sha.cpp
├── tc_shm.cpp
├── tc_socket.cpp
├── tc_socket_async.cpp
├── tc_spin_lock.cpp
├── tc_split.cpp
├── tc_strptime.cpp
├── tc_tea.cpp
├── tc_thread.cpp
├── tc_thread_cond.cpp
├── tc_thread_mutex.cpp
├── tc_thread_pool.cpp
├── tc_thread_rwlock.cpp
├── tc_timeprovider.cpp
├── tc_timer.cpp
├── tc_transceiver.cpp
└── tc_xml.cpp
/.github/workflows/ccpp-linux.yml:
--------------------------------------------------------------------------------
1 | name: C/C++ linux
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 |
8 | jobs:
9 | build:
10 |
11 | runs-on: ubuntu-latest
12 |
13 | steps:
14 | - uses: actions/checkout@v2
15 | - name: install
16 | run: sudo apt-get install -y bison flex cmake psmisc libncurses5-dev zlib1g-dev; cmake --version
17 | - name: git
18 | run: git submodule update --init --recursive
19 | - name: configure
20 | run: mkdir build;cd build;cmake .. -DTARS_MYSQL=ON -DTARS_SSL=ON -DTARS_HTTP2=ON -DTARS_PROTOBUF=ON
21 | - name: make
22 | run: cd build; make -j4
23 |
24 |
--------------------------------------------------------------------------------
/.github/workflows/ccpp-mac.yml:
--------------------------------------------------------------------------------
1 | name: C/C++ mac
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 |
8 | jobs:
9 | build:
10 |
11 | runs-on: macos-latest
12 |
13 | steps:
14 | - uses: actions/checkout@v2
15 | - name: install
16 | run: brew install bison flex cmake; cmake --version
17 | - name: git
18 | run: git submodule update --init --recursive
19 | - name: configure
20 | run: mkdir build;cd build;cmake .. -DTARS_MYSQL=ON -DTARS_SSL=ON -DTARS_HTTP2=ON -DTARS_PROTOBUF=ON
21 | - name: make
22 | run: cd build; make -j4
23 |
24 |
--------------------------------------------------------------------------------
/.github/workflows/ccpp-win.yml:
--------------------------------------------------------------------------------
1 | name: C/C++ win
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 |
8 | jobs:
9 | build:
10 |
11 | runs-on: windows-2019
12 |
13 | steps:
14 | - uses: actions/checkout@v2
15 | - uses: shogo82148/actions-setup-perl@v1
16 | with:
17 | perl-version: '5.32'
18 | distribution: strawberry
19 | - run: perl -V
20 | - name: git
21 | run: git submodule update --init --recursive
22 | - name: configure
23 | run: mkdir build;cd build; cmake --version; cmake .. -A X64 -DTARS_MYSQL=ON -DTARS_PROTOBUF=ON -DTARS_SSL=ON
24 | - name: make
25 | run: cd build; cmake --build . --config release
26 |
--------------------------------------------------------------------------------
/.github/workflows/gitee-sync.yml:
--------------------------------------------------------------------------------
1 | on:
2 | push:
3 | branches:
4 | - master
5 | tags:
6 | - "*"
7 |
8 | name: Sync to Gitee
9 | jobs:
10 | run:
11 | name: Run
12 | runs-on: ubuntu-latest
13 | steps:
14 | - name: Checkout source code
15 | uses: actions/checkout@v1
16 | - name: Mirror Github to Gitee
17 | uses: Yikun/hub-mirror-action@v1.2
18 | with:
19 | src: github/TarsCloud
20 | dst: gitee/TarsCloud
21 | dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
22 | dst_token: ${{ secrets.GITEE_TOKEN }}
23 | account_type: org
24 | timeout: 600
25 | debug: true
26 | force_update: true
27 | static_list: "TarsCpp"
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | servant/makefile/tars-tools.cmake
2 | .idea
3 | /cmake-build-debug-177
4 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "servant/protocol"]
2 | path = servant/protocol
3 | url = https://github.com/TarsCloud/TarsProtocol.git
4 |
--------------------------------------------------------------------------------
/Contributing.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | If you contributed but cannot find your ID here, please submit PR and add your GitHub ID to both [Tars repo](https://github.com/TarsCloud/Tars/pulls) and [here](https://github.com/TarsCloud/TarsCpp/pulls).
4 |
5 | ## TarsCpp
6 |
7 | - Abioy
8 | - jerrylucky
9 | - langio
10 | - ruanshudong
11 | - shevqko
12 | - Spacebody
13 | - TCZWJ
14 | - viest
15 | - YMChenLiye
16 | - zhanleewo
17 | - BeyondWUXF
18 | -
19 |
--------------------------------------------------------------------------------
/README.zh.md:
--------------------------------------------------------------------------------
1 | Tars整体介绍文档请阅读: https://tarscloud.gitbook.io/
2 |
3 | 该工程是Tars RPC框架C++语言的源代码
4 |
5 | 目录名称 |功能
6 | ------------------|----------------
7 | [servant](https://github.com/TarsCloud/TarsCpp/tree/master/servant) |C++语言框架rpc的源码实现
8 | [tools](https://github.com/TarsCloud/TarsCpp/tree/master/tools) |C++语言框架IDL工具的源码实现
9 | [util](https://github.com/TarsCloud/TarsCpp/tree/master/util) |C++语言框架基础工具库的源码实现
10 | [examples](https://github.com/TarsCloud/TarsCpp/tree/master/examples) |C++语言框架的示例代码,包括:快速入门示例、promise编程入门示例、压测程序示例
11 | [unittest](https://github.com/TarsCloud/tars-unittest/tree/master) |tars cpp rpc框架的单元测试用例,基于GoogleTest开发;可以使用命令'git submodule init unittest;git submodule update'作为git子模块下载
12 | [test_deprecated](https://github.com/TarsCloud/TarsCpp/tree/master/test) |C++语言框架各个部分的测试程序,已弃用
13 | [docs](https://github.com/TarsCloud/TarsCpp/tree/master/docs) |文档说明
14 | [docs-en](https://github.com/TarsCloud/TarsCpp/tree/master/docs-en) |英文文档说明
15 |
16 | 依赖环境
17 |
18 | 软件 |软件要求
19 | ------|--------
20 | linux内核版本: | 2.6.18及以上版本
21 | gcc版本: | 4.1.2及以上版本、glibc-devel
22 | bison工具版本: | 2.5及以上版本
23 | flex工具版本: | 2.5及以上版本
24 | cmake版本: | 3.2及以上版本
25 | mysql版本: | 4.1.17及以上版本
26 |
27 | 编译和安装
28 | ```
29 | git clone https://github.com/TarsCloud/TarsCpp.git --recursive
30 | cd TarsCpp
31 | cmake .
32 | make
33 | make install
34 | ```
35 |
36 | 详细安装参见[案例文档](https://tarscloud.github.io/TarsDocs/)
37 |
--------------------------------------------------------------------------------
/cross-compiler.cmake:
--------------------------------------------------------------------------------
1 | # configure cross compilation
2 | set(CMAKE_SYSTEM_NAME Linux)
3 | set(CMAKE_SYSTEM_PROCESSOR aarch)
4 |
5 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
6 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
7 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
8 |
9 | SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb")
10 | SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O2 -Wall")
11 |
12 | # you need to set the path to the cross compiler
13 | set(TOOLCHAIN_DIR /root/boat/gcc-linaro-5.4.1-2017.01-x86_64_arm-linux-gnueabi)
14 | set(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}/bin/arm-linux-gnueabi-gcc)
15 | set(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}/bin/arm-linux-gnueabi-g++)
16 |
17 |
--------------------------------------------------------------------------------
/docs-en/README.md:
--------------------------------------------------------------------------------
1 | [Tars C++ usage documentation](https://tarscloud.github.io/TarsDocs_en/SUMMARY.html)
2 |
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | [Tars C++语言使用文档](https://tarscloud.github.io/TarsDocs/SUMMARY.html)
2 |
3 |
--------------------------------------------------------------------------------
/examples/AuthDemo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | include_directories(Server)
3 | add_subdirectory(Server)
4 | add_subdirectory(Client)
5 |
6 |
--------------------------------------------------------------------------------
/examples/AuthDemo/Client/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("AuthClient" "AuthServer")
--------------------------------------------------------------------------------
/examples/AuthDemo/Client/config.conf:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | #tarsregistry locator
6 | locator = tars.tarsregistry.QueryObj@tcp -h 127.0.0.1 -p 17890
7 | #max invoke timeout
8 | sync-invoke-timeout = 5000
9 | #refresh endpoint interval
10 | refresh-endpoint-interval = 10000
11 | #stat obj
12 | stat = tars.tarsstat.StatObj
13 | #max send queue length limit
14 | sendqueuelimit = 100000
15 | #async queue length limit
16 | asyncqueuecap = 100000
17 | #async callback thread num
18 | asyncthread = 3
19 | #net thread
20 | netthread = 1
21 | #merge net and sync thread
22 | mergenetasync = 0
23 | #module name
24 | modulename = TestApp.AuthClient
25 |
26 |
27 | #auth access key
28 | accesskey = tars-test-user
29 | #auth secret key
30 | secretkey = 123456
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/examples/AuthDemo/Server/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("AuthServer" "")
2 |
--------------------------------------------------------------------------------
/examples/AuthDemo/Server/Hello.tars:
--------------------------------------------------------------------------------
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 | module TestApp
18 | {
19 |
20 | interface Hello
21 | {
22 | int test();
23 | int testHello(string sReq, out string sRsp);
24 | };
25 |
26 | };
27 |
--------------------------------------------------------------------------------
/examples/AuthDemo/Server/HelloImp.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 "HelloImp.h"
18 | #include "servant/Application.h"
19 |
20 | using namespace std;
21 |
22 | //////////////////////////////////////////////////////
23 | void HelloImp::initialize()
24 | {
25 | //initialize servant here:
26 | //...
27 | }
28 |
29 | //////////////////////////////////////////////////////
30 | void HelloImp::destroy()
31 | {
32 | //destroy servant here:
33 | //...
34 | }
35 |
36 | int HelloImp::testHello(const std::string &sReq, std::string &sRsp, tars::TarsCurrentPtr current)
37 | {
38 | // TLOGDEBUG("HelloImp::testHellosReq:"<
21 | #include "servant/Application.h"
22 |
23 | using namespace tars;
24 |
25 | /**
26 | *
27 | **/
28 | class HelloServer : public Application
29 | {
30 | public:
31 | /**
32 | *
33 | **/
34 | virtual ~HelloServer() {};
35 |
36 | /**
37 | *
38 | **/
39 | virtual void initialize();
40 |
41 | /**
42 | *
43 | **/
44 | virtual void destroyApp();
45 | };
46 |
47 | extern HelloServer g_app;
48 |
49 | ////////////////////////////////////////////
50 | #endif
51 |
--------------------------------------------------------------------------------
/examples/ClientDemo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | build_tars_server("ClientDemo" "")
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/examples/CoroutineDemo/AServer/AServant.tars:
--------------------------------------------------------------------------------
1 |
2 | module Test
3 | {
4 |
5 | interface AServant
6 | {
7 | int test();
8 |
9 | int testInt(int iIn,out int iOut);
10 |
11 | int testStr(string sIn, out string sOut);
12 | };
13 |
14 | };
15 |
--------------------------------------------------------------------------------
/examples/CoroutineDemo/AServer/AServer.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 _AServer_H_
18 | #define _AServer_H_
19 |
20 | #include
21 | #include "servant/Application.h"
22 |
23 | using namespace tars;
24 |
25 | /**
26 | *
27 | **/
28 | class AServer : public Application
29 | {
30 | public:
31 | /**
32 | *
33 | **/
34 | virtual ~AServer() {};
35 |
36 | /**
37 | *
38 | **/
39 | virtual void initialize();
40 |
41 | /**
42 | *
43 | **/
44 | virtual void destroyApp();
45 |
46 | };
47 |
48 | extern AServer g_app;
49 |
50 | ////////////////////////////////////////////
51 | #endif
52 |
--------------------------------------------------------------------------------
/examples/CoroutineDemo/AServer/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("CoroutineDemoAServer" "")
2 |
--------------------------------------------------------------------------------
/examples/CoroutineDemo/BServer/BServant.tars:
--------------------------------------------------------------------------------
1 |
2 | module Test
3 | {
4 |
5 | interface BServant
6 | {
7 | int test();
8 |
9 | int testCoroSerial(string sIn, out string sOut);
10 |
11 | int testCoroParallel(string sIn, out string sOut);
12 |
13 | };
14 |
15 | };
16 |
--------------------------------------------------------------------------------
/examples/CoroutineDemo/BServer/BServer.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 _BServer_H_
18 | #define _BServer_H_
19 |
20 | #include
21 | #include "servant/Application.h"
22 |
23 | using namespace tars;
24 |
25 | /**
26 | *
27 | **/
28 | class BServer : public Application
29 | {
30 | public:
31 | /**
32 | *
33 | **/
34 | virtual ~BServer() {};
35 |
36 | /**
37 | *
38 | **/
39 | virtual void initialize();
40 |
41 | /**
42 | *
43 | **/
44 | virtual void destroyApp();
45 |
46 | };
47 |
48 | extern BServer g_app;
49 |
50 | ////////////////////////////////////////////
51 | #endif
52 |
--------------------------------------------------------------------------------
/examples/CoroutineDemo/BServer/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("CoroutineDemoBServer" "CoroutineDemoAServer")
--------------------------------------------------------------------------------
/examples/CoroutineDemo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | include_directories(AServer)
3 | add_subdirectory(AServer)
4 |
5 | include_directories(BServer)
6 | add_subdirectory(BServer)
7 |
8 | add_subdirectory(client)
9 | add_subdirectory(testCoro)
10 | add_subdirectory(testParallelCoro)
11 |
12 |
--------------------------------------------------------------------------------
/examples/CoroutineDemo/README.md:
--------------------------------------------------------------------------------
1 | 该工程是Tars 协程编程示例的代码
2 |
3 |
4 | 目录名称 |功能
5 | -----------------|----------------
6 | client/BServer/AServer | 协程编程的示例程序,client访问BServer,BServer用协程方式去并行和串行访问AServer
7 | testCoro/testParallelCoro | 协程编程的示例程序,自定义或者继承框架的协程类
8 |
--------------------------------------------------------------------------------
/examples/CoroutineDemo/client/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("CoroutineDemoClient" "CoroutineDemoAServer CoroutineDemoBServer")
--------------------------------------------------------------------------------
/examples/CoroutineDemo/testCoro/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("testCoro" "CoroutineDemoAServer CoroutineDemoBServer")
--------------------------------------------------------------------------------
/examples/CoroutineDemo/testParallelCoro/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("testParallelCoro" "CoroutineDemoAServer CoroutineDemoBServer")
--------------------------------------------------------------------------------
/examples/CustomDemo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | add_subdirectory(CustomClient)
3 | add_subdirectory(CustomServer)
4 |
5 |
--------------------------------------------------------------------------------
/examples/CustomDemo/CustomClient/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("CustomClient" "CustomServer")
--------------------------------------------------------------------------------
/examples/CustomDemo/CustomServer/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("CustomServer" "")
--------------------------------------------------------------------------------
/examples/CustomDemo/CustomServer/CustomServantImp.cpp:
--------------------------------------------------------------------------------
1 | #include "CustomServantImp.h"
2 | #include "servant/Application.h"
3 |
4 | using namespace std;
5 |
6 | //////////////////////////////////////////////////////
7 | void CustomServantImp::initialize()
8 | {
9 | //initialize servant here:
10 | //...
11 | }
12 |
13 | //////////////////////////////////////////////////////
14 | void CustomServantImp::destroy()
15 | {
16 | //destroy servant here:
17 | //...
18 | }
19 |
20 |
21 | int CustomServantImp::doRequest(tars::TarsCurrentPtr current, vector& response)
22 | {
23 | //Return to the data package requested by the client itself, that is, the original package return (4-byte length + 4-byte request + buffer)
24 | const vector& request = current->getRequestBuffer();
25 | response = request;
26 |
27 | // cout << "doRequest: requestId:" << current->getRequestId() << ", funcName:" << current->getFuncName() << endl;
28 | return 0;
29 | }
30 |
31 | int CustomServantImp::doClose(TarsCurrentPtr current)
32 | {
33 | LOG->debug() << "close ip: " << current->getIp() << endl;
34 |
35 | return 0;
36 | }
37 |
38 |
39 |
--------------------------------------------------------------------------------
/examples/CustomDemo/CustomServer/CustomServantImp.h:
--------------------------------------------------------------------------------
1 | #ifndef _CustomServantImp_H_
2 | #define _CustomServantImp_H_
3 |
4 | #include "servant/Application.h"
5 | //#include "CustomServant.h"
6 |
7 | /**
8 | *
9 | *
10 | */
11 | class CustomServantImp : public tars::Servant
12 | {
13 | public:
14 | /**
15 | *
16 | */
17 | virtual ~CustomServantImp() {}
18 |
19 | /**
20 | *
21 | */
22 | virtual void initialize();
23 |
24 | /**
25 | *
26 | */
27 | virtual void destroy();
28 |
29 | //overloading method of Servant::doRequest
30 | int doRequest(tars::TarsCurrentPtr current, vector& response);
31 |
32 | //overloading method of Servant::doClose
33 | int doClose(tars::TarsCurrentPtr current);
34 |
35 | };
36 | /////////////////////////////////////////////////////
37 | #endif
38 |
--------------------------------------------------------------------------------
/examples/CustomDemo/CustomServer/CustomServer.h:
--------------------------------------------------------------------------------
1 | #ifndef _CustomServer_H_
2 | #define _CustomServer_H_
3 |
4 | #include
5 | #include "servant/Application.h"
6 |
7 | using namespace tars;
8 |
9 | /**
10 | *
11 | **/
12 | class CustomServer : public Application
13 | {
14 | public:
15 | /**
16 | *
17 | **/
18 | virtual ~CustomServer() {};
19 |
20 | /**
21 | *
22 | **/
23 | virtual void initialize();
24 |
25 | /**
26 | *
27 | **/
28 | virtual void destroyApp();
29 |
30 | };
31 |
32 | extern CustomServer g_app;
33 |
34 | ////////////////////////////////////////////
35 | #endif
36 |
--------------------------------------------------------------------------------
/examples/CustomDemo/README.md:
--------------------------------------------------------------------------------
1 | 该工程是Tars快速入门示例的代码
2 |
3 |
4 | 目录名称 |功能
5 | -----------------|----------------
6 | HelloServer | 开发快速入门的示例
7 | ProxyServer | 中转代理服务示例,作为HelloServer的代理服务
--------------------------------------------------------------------------------
/examples/GrpcDemo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_subdirectory(GrpcClient)
2 | add_subdirectory(GrpcServer)
3 |
--------------------------------------------------------------------------------
/examples/GrpcDemo/GrpcClient/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("GrpcClient" "GrpcServer")
2 |
--------------------------------------------------------------------------------
/examples/GrpcDemo/GrpcClient/helloworld.proto:
--------------------------------------------------------------------------------
1 | // Copyright 2015 gRPC authors.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | syntax = "proto3";
16 |
17 | option java_multiple_files = true;
18 | option java_package = "io.grpc.examples.helloworld";
19 | option java_outer_classname = "HelloWorldProto";
20 | option objc_class_prefix = "HLW";
21 |
22 | package helloworld;
23 |
24 | // The greeting service definition.
25 | service Greeter {
26 | // Sends a greeting
27 | rpc SayHello (HelloRequest) returns (HelloReply) {}
28 | }
29 |
30 | // The request message containing the user's name.
31 | message HelloRequest {
32 | string name = 1;
33 | }
34 |
35 | // The response message containing the greetings
36 | message HelloReply {
37 | string message = 1;
38 | }
39 |
--------------------------------------------------------------------------------
/examples/GrpcDemo/GrpcServer/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("GrpcServer" "")
2 |
--------------------------------------------------------------------------------
/examples/GrpcDemo/GrpcServer/GrpcServer.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 _GrpcServer_H_
18 | #define _GrpcServer_H_
19 |
20 | #include
21 | #include "servant/Application.h"
22 | #include "util/tc_grpc.h"
23 |
24 | using namespace tars;
25 |
26 | /**
27 | *
28 | **/
29 | class GrpcServer : public Application
30 | {
31 | public:
32 | /**
33 | *
34 | **/
35 | virtual ~GrpcServer() {};
36 |
37 | /**
38 | *
39 | **/
40 | virtual void initialize();
41 |
42 | /**
43 | *
44 | **/
45 | virtual void destroyApp();
46 | };
47 |
48 | extern GrpcServer g_app;
49 |
50 | ////////////////////////////////////////////
51 | #endif
52 |
--------------------------------------------------------------------------------
/examples/GrpcDemo/GrpcServer/helloworld.proto:
--------------------------------------------------------------------------------
1 | // Copyright 2015 gRPC authors.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | syntax = "proto3";
16 |
17 | option java_multiple_files = true;
18 | option java_package = "io.grpc.examples.helloworld";
19 | option java_outer_classname = "HelloWorldProto";
20 | option objc_class_prefix = "HLW";
21 |
22 | package helloworld;
23 |
24 | // The greeting service definition.
25 | service Greeter {
26 | // Sends a greeting
27 | rpc SayHello (HelloRequest) returns (HelloReply) {}
28 | }
29 |
30 | // The request message containing the user's name.
31 | message HelloRequest {
32 | string name = 1;
33 | }
34 |
35 | // The response message containing the greetings
36 | message HelloReply {
37 | string message = 1;
38 | }
39 |
--------------------------------------------------------------------------------
/examples/HttpDemo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | add_subdirectory(HttpClient)
3 | add_subdirectory(HttpServer)
4 |
5 | if(TARS_HTTP2)
6 | add_subdirectory(Http2Client)
7 | add_subdirectory(Http2Server)
8 | endif()
--------------------------------------------------------------------------------
/examples/HttpDemo/Http2Client/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("Http2Client" "Http2Server")
2 |
--------------------------------------------------------------------------------
/examples/HttpDemo/Http2Server/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("Http2Server" "")
2 |
--------------------------------------------------------------------------------
/examples/HttpDemo/Http2Server/HttpServer.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 _HttpServer_H_
18 | #define _HttpServer_H_
19 |
20 | #include
21 | #include "servant/Application.h"
22 |
23 | using namespace tars;
24 |
25 | /**
26 | *
27 | **/
28 | class HttpServer : public Application
29 | {
30 | public:
31 | /**
32 | *
33 | **/
34 | virtual ~HttpServer() {};
35 |
36 | /**
37 | *
38 | **/
39 | virtual void initialize();
40 |
41 | /**
42 | *
43 | **/
44 | virtual void destroyApp();
45 | };
46 |
47 | extern HttpServer g_app;
48 |
49 | ////////////////////////////////////////////
50 | #endif
51 |
--------------------------------------------------------------------------------
/examples/HttpDemo/HttpClient/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | #build_tars_server("HttpClient" "HttpServer")
2 | build_tars_server("HttpClient" "")
--------------------------------------------------------------------------------
/examples/HttpDemo/HttpServer/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("HttpServer" "")
--------------------------------------------------------------------------------
/examples/HttpDemo/HttpServer/HttpImp.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 _HttpImp_H_
18 | #define _HttpImp_H_
19 |
20 | #include "servant/Application.h"
21 |
22 | /**
23 | *
24 | *
25 | */
26 | class HttpImp : public Servant
27 | {
28 | public:
29 | /**
30 | *
31 | */
32 | virtual ~HttpImp() {}
33 |
34 | /**
35 | *
36 | */
37 | virtual void initialize();
38 |
39 | /**
40 | *
41 | */
42 | virtual void destroy();
43 |
44 | /**
45 | *
46 | */
47 | int doRequest(TarsCurrentPtr current, vector &buffer);
48 |
49 | };
50 | /////////////////////////////////////////////////////
51 | #endif
52 |
--------------------------------------------------------------------------------
/examples/HttpDemo/HttpServer/HttpServer.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 _HttpServer_H_
18 | #define _HttpServer_H_
19 |
20 | #include
21 | #include "servant/Application.h"
22 |
23 | using namespace tars;
24 |
25 | /**
26 | *
27 | **/
28 | class HttpServer : public Application
29 | {
30 | public:
31 | /**
32 | *
33 | **/
34 | virtual ~HttpServer() {};
35 |
36 | /**
37 | *
38 | **/
39 | virtual void initialize();
40 |
41 | /**
42 | *
43 | **/
44 | virtual void destroyApp();
45 |
46 | private:
47 | void onNewClient(TC_EpollServer::Connection*);
48 | };
49 |
50 | extern HttpServer g_app;
51 |
52 | ////////////////////////////////////////////
53 | #endif
54 |
--------------------------------------------------------------------------------
/examples/PromiseDemo/AServer/AServant.tars:
--------------------------------------------------------------------------------
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 | module Test
18 | {
19 |
20 | interface AServant
21 | {
22 | int queryResultSerial(string sIn, out string sOut);
23 |
24 | int queryResultParallel(string sIn, out string sOut);
25 | };
26 |
27 | };
28 |
--------------------------------------------------------------------------------
/examples/PromiseDemo/AServer/AServer.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 _BServer_H_
18 | #define _BServer_H_
19 |
20 | #include
21 | #include "servant/Application.h"
22 |
23 | using namespace tars;
24 |
25 | /**
26 | *
27 | **/
28 | class AServer : public Application
29 | {
30 | public:
31 | /**
32 | *
33 | **/
34 | virtual ~AServer() {};
35 |
36 | /**
37 | *
38 | **/
39 | virtual void initialize();
40 |
41 | /**
42 | *
43 | **/
44 | virtual void destroyApp();
45 | protected:
46 | bool cmdprofile(const string& command, const string& params, string& result);
47 | };
48 |
49 | extern AServer g_app;
50 |
51 | ////////////////////////////////////////////
52 | #endif
53 |
--------------------------------------------------------------------------------
/examples/PromiseDemo/AServer/BServant.tars:
--------------------------------------------------------------------------------
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 | module Test
18 | {
19 |
20 | interface BServant
21 | {
22 | int queryResult(string sIn, out string sOut);
23 | };
24 |
25 | };
26 |
--------------------------------------------------------------------------------
/examples/PromiseDemo/AServer/CServant.tars:
--------------------------------------------------------------------------------
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 | module Test
18 | {
19 |
20 | interface CServant
21 | {
22 | int queryResult(string sIn, out string sOut);
23 | };
24 |
25 | };
26 |
--------------------------------------------------------------------------------
/examples/PromiseDemo/AServer/makefile:
--------------------------------------------------------------------------------
1 |
2 | #-----------------------------------------------------------------------
3 | APP := Test
4 | TARGET := AServer
5 | CONFIG :=
6 | STRIP_FLAG:= N
7 |
8 | INCLUDE +=
9 |
10 | #-----------------------------------------------------------------------
11 | include /usr/local/tars/cpp/makefile/makefile.tars
12 | #-----------------------------------------------------------------------
13 |
--------------------------------------------------------------------------------
/examples/PromiseDemo/BServer/BServant.tars:
--------------------------------------------------------------------------------
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 | module Test
18 | {
19 |
20 | interface BServant
21 | {
22 | int queryResult(string sIn, out string sOut);
23 | };
24 |
25 | };
26 |
--------------------------------------------------------------------------------
/examples/PromiseDemo/BServer/BServantImp.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 _BServantImp_H_
18 | #define _BServantImp_H_
19 |
20 | #include "servant/Application.h"
21 | #include "BServant.h"
22 | #include "promise/promise.h"
23 |
24 | using namespace Test;
25 |
26 | class BServantImp : public Test::BServant
27 | {
28 | public:
29 |
30 | virtual ~BServantImp() {}
31 |
32 | virtual void initialize();
33 |
34 | virtual void destroy();
35 |
36 | tars::Int32 queryResult(const std::string& sIn, std::string &sOut, tars::TarsCurrentPtr current);
37 |
38 | };
39 | /////////////////////////////////////////////////////
40 | #endif
41 |
--------------------------------------------------------------------------------
/examples/PromiseDemo/BServer/BServer.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 _BServer_H_
18 | #define _BServer_H_
19 |
20 | #include
21 | #include "servant/Application.h"
22 |
23 | using namespace tars;
24 |
25 | /**
26 | *
27 | **/
28 | class BServer : public Application
29 | {
30 | public:
31 | /**
32 | *
33 | **/
34 | virtual ~BServer() {};
35 |
36 | /**
37 | *
38 | **/
39 | virtual void initialize();
40 |
41 | /**
42 | *
43 | **/
44 | virtual void destroyApp();
45 | protected:
46 | bool cmdprofile(const string& command, const string& params, string& result);
47 | };
48 |
49 | extern BServer g_app;
50 |
51 | ////////////////////////////////////////////
52 | #endif
53 |
--------------------------------------------------------------------------------
/examples/PromiseDemo/BServer/makefile:
--------------------------------------------------------------------------------
1 | #-----------------------------------------------------------------------
2 |
3 | APP := Test
4 | TARGET := BServer
5 | CONFIG :=
6 | STRIP_FLAG:= N
7 | INCLUDE +=
8 |
9 | #-----------------------------------------------------------------------
10 | include /usr/local/tars/cpp/makefile/makefile.tars
11 | #-----------------------------------------------------------------------
12 |
--------------------------------------------------------------------------------
/examples/PromiseDemo/CServer/CServant.tars:
--------------------------------------------------------------------------------
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 | module Test
18 | {
19 |
20 | interface CServant
21 | {
22 | int queryResult(string sIn, out string sOut);
23 | };
24 |
25 | };
26 |
--------------------------------------------------------------------------------
/examples/PromiseDemo/CServer/CServantImp.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 _BServantImp_H_
18 | #define _BServantImp_H_
19 |
20 | #include "servant/Application.h"
21 | #include "CServant.h"
22 | #include "promise/promise.h"
23 |
24 | using namespace Test;
25 |
26 | class CServantImp : public Test::CServant
27 | {
28 | public:
29 |
30 | virtual ~CServantImp() {}
31 |
32 | virtual void initialize();
33 |
34 | virtual void destroy();
35 |
36 | tars::Int32 queryResult(const std::string& sIn, std::string &sOut, tars::TarsCurrentPtr current);
37 |
38 | };
39 | /////////////////////////////////////////////////////
40 | #endif
41 |
--------------------------------------------------------------------------------
/examples/PromiseDemo/CServer/CServer.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 _BServer_H_
18 | #define _BServer_H_
19 |
20 | #include
21 | #include "servant/Application.h"
22 |
23 | using namespace tars;
24 |
25 | /**
26 | * *
27 | * **/
28 | class CServer : public Application
29 | {
30 | public:
31 | /**
32 | *
33 | **/
34 | virtual ~CServer() {};
35 |
36 | /**
37 | *
38 | **/
39 | virtual void initialize();
40 |
41 | /**
42 | *
43 | **/
44 | virtual void destroyApp();
45 | protected:
46 | bool cmdprofile(const string& command, const string& params, string& result);
47 | };
48 |
49 | extern CServer g_app;
50 |
51 | ////////////////////////////////////////////
52 | #endif
53 |
54 |
--------------------------------------------------------------------------------
/examples/PromiseDemo/CServer/makefile:
--------------------------------------------------------------------------------
1 | #-----------------------------------------------------------------------
2 | APP := Test
3 | TARGET := CServer
4 | CONFIG :=
5 | STRIP_FLAG:= N
6 |
7 | INCLUDE +=
8 |
9 | #-----------------------------------------------------------------------
10 | include /usr/local/tars/cpp/makefile/makefile.tars
11 | #-----------------------------------------------------------------------
12 |
--------------------------------------------------------------------------------
/examples/PromiseDemo/Client/makefile:
--------------------------------------------------------------------------------
1 |
2 | #-----------------------------------------------------------------------
3 | APP := Test
4 | TARGET := myClientPromise
5 | CONFIG :=
6 | STRIP_FLAG:= N
7 |
8 | INCLUDE +=
9 |
10 | #-----------------------------------------------------------------------
11 | include /home/tarsproto/Test/AServer/AServer.mk
12 | include /usr/local/tars/cpp/makefile/makefile.tars
13 | #-----------------------------------------------------------------------
14 |
--------------------------------------------------------------------------------
/examples/PromiseDemo/README.md:
--------------------------------------------------------------------------------
1 | 该工程是Tars promise编程示例的代码
2 |
3 |
4 | 目录名称 |功能
5 | -----------------|----------------
6 | AServer | promise编程的示例程序,用promsie方式去并行和串行访问BServer和CServer
7 |
--------------------------------------------------------------------------------
/examples/PushCallbackDemo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | include_directories(Server)
3 | add_subdirectory(Server)
4 | add_subdirectory(Client)
5 |
6 |
--------------------------------------------------------------------------------
/examples/PushCallbackDemo/Client/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("PushCallbackClient" "PushCallbackServer")
--------------------------------------------------------------------------------
/examples/PushCallbackDemo/Client/config.conf:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | #tarsregistry locator
6 | locator = tars.tarsregistry.QueryObj@tcp -h 127.0.0.1 -p 17890
7 | #max invoke timeout
8 | sync-invoke-timeout = 5000
9 | #refresh endpoint interval
10 | refresh-endpoint-interval = 10000
11 | #stat obj
12 | stat = tars.tarsstat.StatObj
13 | #max send queue length limit
14 | sendqueuelimit = 100000
15 | #async queue length limit
16 | asyncqueuecap = 100000
17 | #async callback thread num
18 | asyncthread = 3
19 | #net thread
20 | netthread = 1
21 | #merge net and sync thread
22 | mergenetasync = 0
23 | #module name
24 | modulename = TestApp.AuthClient
25 |
26 |
27 | #auth access key
28 | accesskey = tars-test-user
29 | #auth secret key
30 | secretkey = 123456
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/examples/PushCallbackDemo/Server/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("PushCallbackServer" "")
2 |
--------------------------------------------------------------------------------
/examples/PushCallbackDemo/Server/Hello.tars:
--------------------------------------------------------------------------------
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 | module TestApp
18 | {
19 |
20 | interface Hello
21 | {
22 | int registerPush();
23 | };
24 |
25 | };
26 |
--------------------------------------------------------------------------------
/examples/PushCallbackDemo/Server/HelloImp.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 "HelloImp.h"
18 | #include "servant/Application.h"
19 | #include "HelloServer.h"
20 |
21 | using namespace std;
22 |
23 | //////////////////////////////////////////////////////
24 | void HelloImp::initialize()
25 | {
26 | //initialize servant here:
27 | //...
28 | }
29 |
30 | //////////////////////////////////////////////////////
31 | void HelloImp::destroy()
32 | {
33 | //destroy servant here:
34 | //...
35 | }
36 |
37 | int HelloImp::doClose(tars::TarsCurrentPtr current)
38 | {
39 | g_app._pushThread.delCurrent(current);
40 | return 0;
41 | }
42 |
43 | int HelloImp::registerPush(tars::TarsCurrentPtr current)
44 | {
45 | g_app._pushThread.addCurrent(current);
46 | return 0;
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/examples/PushCallbackDemo/Server/HelloServer.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 _HelloServer_H_
18 | #define _HelloServer_H_
19 |
20 | #include
21 | #include "servant/Application.h"
22 | #include "PushThread.h"
23 |
24 | using namespace tars;
25 |
26 | /**
27 | *
28 | **/
29 | class HelloServer : public Application
30 | {
31 | public:
32 | /**
33 | *
34 | **/
35 | virtual ~HelloServer() {};
36 |
37 | /**
38 | *
39 | **/
40 | virtual void initialize();
41 |
42 | /**
43 | *
44 | **/
45 | virtual void destroyApp();
46 |
47 | PushThread _pushThread;
48 | };
49 |
50 | extern HelloServer g_app;
51 |
52 | ////////////////////////////////////////////
53 | #endif
54 |
--------------------------------------------------------------------------------
/examples/PushCallbackDemo/Server/Push.tars:
--------------------------------------------------------------------------------
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 | module TestApp
18 | {
19 |
20 | interface Push
21 | {
22 | int pushMsg(out string sRsp);
23 | };
24 |
25 | };
26 |
--------------------------------------------------------------------------------
/examples/PushCallbackDemo/Server/PushThread.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by jarod on 2022/9/7.
3 | //
4 |
5 | #include "PushThread.h"
6 | #include "Push.h"
7 |
8 | void PushThread::terminate()
9 | {
10 | std::lock_guard lock(_mutex);
11 | _terminate = true;
12 | _cond.notify_one();
13 |
14 | }
15 |
16 | void PushThread::addCurrent(CurrentPtr ¤t)
17 | {
18 | std::lock_guard lock(_mutex);
19 |
20 | _currents[current->getUId()] = current;
21 | }
22 |
23 | void PushThread::delCurrent(CurrentPtr ¤t)
24 | {
25 | std::lock_guard lock(_mutex);
26 |
27 | _currents.erase(current->getUId());
28 | }
29 |
30 | void PushThread::run()
31 | {
32 | while(!_terminate)
33 | {
34 | std::unique_lock lock(_mutex);
35 |
36 | for(auto it : _currents)
37 | {
38 | TestApp::Push::async_response_push_pushMsg(it.second, 0, "push message");
39 | }
40 |
41 | _cond.wait_for(lock, std::chrono::milliseconds(1000));
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/examples/PushCallbackDemo/Server/PushThread.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by jarod on 2022/9/7.
3 | //
4 |
5 | #ifndef FRAMEWORK_PUSHTHREAD_H
6 | #define FRAMEWORK_PUSHTHREAD_H
7 |
8 | #include
9 | #include "util/tc_thread.h"
10 | #include "servant/Application.h"
11 | using namespace tars;
12 |
13 | class PushThread : public TC_Thread
14 | {
15 | public:
16 | void addCurrent(CurrentPtr ¤t);
17 | void delCurrent(CurrentPtr ¤t);
18 |
19 | void terminate();
20 | protected:
21 | virtual void run();
22 |
23 | protected:
24 | bool _terminate = false;
25 | std::mutex _mutex;
26 | std::condition_variable _cond;
27 | map _currents;
28 | };
29 |
30 |
31 |
32 | #endif //FRAMEWORK_PUSHTHREAD_H
33 |
--------------------------------------------------------------------------------
/examples/PushDemo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | add_subdirectory(PushClient)
3 | add_subdirectory(PushServer)
4 |
5 |
--------------------------------------------------------------------------------
/examples/PushDemo/PushClient/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("PushClient" "PushServer")
--------------------------------------------------------------------------------
/examples/PushDemo/PushClient/TestRecvThread.h:
--------------------------------------------------------------------------------
1 | #ifndef __TEST_RECV_THREAD_H
2 | #define __TEST_RECV_THREAD_H
3 |
4 | #include "servant/Application.h"
5 |
6 | class TestPushCallBack : public ServantProxyCallback
7 | {
8 | public:
9 | virtual int onDispatch(ReqMessagePtr msg);
10 | };
11 |
12 | typedef tars::TC_AutoPtr TestPushCallBackPtr;
13 |
14 | class RecvThread : public TC_Thread, public TC_ThreadLock
15 | {
16 | public:
17 | RecvThread(int second);
18 |
19 | virtual void run();
20 |
21 | private:
22 | int _second;
23 | bool _bTerminate;
24 |
25 | Communicator _comm;
26 |
27 | ServantPrx _prx;
28 | };
29 | #endif
30 |
--------------------------------------------------------------------------------
/examples/PushDemo/PushClient/main.cpp:
--------------------------------------------------------------------------------
1 | #include "servant/Application.h"
2 | #include "TestRecvThread.h"
3 | #include
4 |
5 | using namespace std;
6 | using namespace tars;
7 |
8 | int main(int argc,char**argv)
9 | {
10 | try
11 | {
12 | int second = 5;
13 |
14 | if(argc > 1)
15 | second = TC_Common::strto(argv[1]);
16 |
17 | if(second <=0 )
18 | second = 1;
19 |
20 | RecvThread thread(second);
21 | thread.start();
22 |
23 | thread.getThreadControl().join();
24 | }
25 | catch(std::exception&e)
26 | {
27 | cerr<<"std::exception:"<& response);
37 |
38 | //重载Servant的doClose方法
39 | int doClose(tars::TarsCurrentPtr current);
40 |
41 | };
42 | /////////////////////////////////////////////////////
43 | #endif
44 |
--------------------------------------------------------------------------------
/examples/PushDemo/PushServer/TestPushServer.h:
--------------------------------------------------------------------------------
1 | #ifndef _TestPushServer_H_
2 | #define _TestPushServer_H_
3 |
4 | #include
5 | #include "servant/Application.h"
6 | #include "TestPushThread.h"
7 |
8 |
9 | using namespace tars;
10 |
11 | /**
12 | *
13 | **/
14 | class TestPushServer : public Application
15 | {
16 | public:
17 | /**
18 | *
19 | **/
20 | virtual ~TestPushServer() {};
21 |
22 | /**
23 | *
24 | **/
25 | virtual void initialize();
26 |
27 | /**
28 | *
29 | **/
30 | virtual void destroyApp();
31 |
32 | private:
33 | //用于push消息的线程
34 | PushInfoThread pushThread;
35 |
36 | };
37 |
38 | extern TestPushServer g_app;
39 |
40 | ////////////////////////////////////////////
41 | #endif
42 |
--------------------------------------------------------------------------------
/examples/PushDemo/PushServer/TestPushThread.h:
--------------------------------------------------------------------------------
1 | #ifndef __TEST_PUSH_THREAD_H
2 | #define __TEST_PUSH_THREAD_H
3 |
4 | #include "servant/Application.h"
5 |
6 | class PushUser
7 | {
8 | public:
9 | static map pushUser;
10 | static TC_ThreadMutex mapMutex;
11 | };
12 |
13 | class PushInfoThread : public TC_Thread, public TC_ThreadLock
14 | {
15 | public:
16 | PushInfoThread():_bTerminate(false), _iId(0){}
17 |
18 | virtual void run();
19 |
20 | void terminate();
21 |
22 | void setPushInfo(const string &sInfo);
23 |
24 | private:
25 | bool _bTerminate;
26 | unsigned int _iId;
27 | string _sPushInfo;
28 | };
29 | #endif
30 |
--------------------------------------------------------------------------------
/examples/PushDemo/README.md:
--------------------------------------------------------------------------------
1 | 该工程是Tars快速入门示例的代码
2 |
3 |
4 | 目录名称 |功能
5 | -----------------|----------------
6 | HelloServer | 开发快速入门的示例
7 | ProxyServer | 中转代理服务示例,作为HelloServer的代理服务
--------------------------------------------------------------------------------
/examples/QuickStartDemo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | include_directories(HelloServer/Server)
3 | add_subdirectory(HelloServer)
4 | add_subdirectory(ProxyServer)
5 |
6 |
--------------------------------------------------------------------------------
/examples/QuickStartDemo/HelloServer/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | include_directories(Server)
3 | add_subdirectory(Server)
4 | add_subdirectory(Client)
--------------------------------------------------------------------------------
/examples/QuickStartDemo/HelloServer/Client/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("QuickStartDemoClient" "QuickStartDemo")
--------------------------------------------------------------------------------
/examples/QuickStartDemo/HelloServer/Server/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("QuickStartDemo" "")
2 |
--------------------------------------------------------------------------------
/examples/QuickStartDemo/HelloServer/Server/Hello.tars:
--------------------------------------------------------------------------------
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 | module TestApp
18 | {
19 |
20 | interface Hello
21 | {
22 | int test();
23 | int testHello(string sReq, out string sRsp);
24 | };
25 |
26 | };
27 |
--------------------------------------------------------------------------------
/examples/QuickStartDemo/HelloServer/Server/HelloServer.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 _HelloServer_H_
18 | #define _HelloServer_H_
19 |
20 | #include
21 | #include "servant/Application.h"
22 |
23 | using namespace tars;
24 |
25 | /**
26 | *
27 | **/
28 | class HelloServer : public Application
29 | {
30 | public:
31 | /**
32 | *
33 | **/
34 | virtual ~HelloServer() {};
35 |
36 | /**
37 | *
38 | **/
39 | virtual void initialize();
40 |
41 | /**
42 | *
43 | **/
44 | virtual void destroyApp();
45 | };
46 |
47 | extern HelloServer g_app;
48 |
49 | ////////////////////////////////////////////
50 | #endif
51 |
--------------------------------------------------------------------------------
/examples/QuickStartDemo/ProxyServer/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | include_directories(Server)
3 | add_subdirectory(Server)
4 | add_subdirectory(Client)
5 |
6 |
--------------------------------------------------------------------------------
/examples/QuickStartDemo/ProxyServer/Client/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("ProxyServerClient" "ProxyServer")
--------------------------------------------------------------------------------
/examples/QuickStartDemo/ProxyServer/Server/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("ProxyServer" "")
2 |
3 |
4 |
--------------------------------------------------------------------------------
/examples/QuickStartDemo/ProxyServer/Server/Proxy.tars:
--------------------------------------------------------------------------------
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 | module TestApp
18 | {
19 |
20 | interface Proxy
21 | {
22 | int test();
23 | int testProxy(string sReq, out string sRsp);
24 | };
25 |
26 | };
27 |
--------------------------------------------------------------------------------
/examples/QuickStartDemo/ProxyServer/Server/ProxyServer.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 __PROXY_SERVER_H_
18 | #define __PROXY_SERVER_H_
19 |
20 | #include
21 | #include "servant/Application.h"
22 |
23 | using namespace tars;
24 |
25 | /**
26 | *
27 | **/
28 | class ProxyServer : public Application
29 | {
30 | public:
31 | /**
32 | *
33 | **/
34 | virtual ~ProxyServer() {};
35 |
36 | /**
37 | *
38 | **/
39 | virtual void initialize();
40 |
41 | /**
42 | *
43 | **/
44 | virtual void destroyApp();
45 | protected:
46 |
47 | };
48 |
49 | extern ProxyServer g_app;
50 |
51 | ////////////////////////////////////////////
52 | #endif
53 |
--------------------------------------------------------------------------------
/examples/QuickStartDemo/README.md:
--------------------------------------------------------------------------------
1 | 该工程是Tars快速入门示例的代码
2 |
3 |
4 | 目录名称 |功能
5 | -----------------|----------------
6 | HelloServer | 开发快速入门的示例
7 | ProxyServer | 中转代理服务示例,作为HelloServer的代理服务
--------------------------------------------------------------------------------
/examples/README.md:
--------------------------------------------------------------------------------
1 | 该工程是Tars入门示例的代码
2 |
3 |
4 | 目录名称 |功能
5 | -----------------|----------------
6 | [QuickStartDemo](https://github.com/TarsCloud/TarsCpp/tree/d687aae51a016c313812c973ec75ab4cad7fbcaa/examples/QuickStartDemo) | 开发快速入门的示例
7 | [PromiseDemo](https://github.com/TarsCloud/TarsCpp/tree/d687aae51a016c313812c973ec75ab4cad7fbcaa/examples/PromiseDemo) | promise编程的示例[]
8 | [HttpDemo](https://github.com/TarsCloud/TarsCpp/tree/d687aae51a016c313812c973ec75ab4cad7fbcaa/examples/HttpDemo) | http服务端的示例
9 | [CoroutineDemo](https://github.com/TarsCloud/TarsCpp/tree/d687aae51a016c313812c973ec75ab4cad7fbcaa/examples/CoroutineDemo) | 协程的示例
10 | [StressDemo](https://github.com/TarsCloud/TarsCpp/tree/d687aae51a016c313812c973ec75ab4cad7fbcaa/examples/StressDemo) | tars c++压测代码
11 | [PushDemo](https://github.com/TarsCloud/TarsCpp/tree/d687aae51a016c313812c973ec75ab4cad7fbcaa/examples/PushDemo) | tars push 模式demo
--------------------------------------------------------------------------------
/examples/SSLDemo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | include_directories(Server)
3 | add_subdirectory(Server)
4 | add_subdirectory(Client)
5 |
6 |
--------------------------------------------------------------------------------
/examples/SSLDemo/Client/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("SSLClient" "SSLServer")
--------------------------------------------------------------------------------
/examples/SSLDemo/Server/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("SSLServer" "")
2 |
--------------------------------------------------------------------------------
/examples/SSLDemo/Server/SSLImp.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 "SSLImp.h"
18 | #include "servant/Application.h"
19 |
20 | using namespace std;
21 |
22 | //////////////////////////////////////////////////////
23 | void SSLImp::initialize()
24 | {
25 | //initialize servant here:
26 | //...
27 | }
28 |
29 | //////////////////////////////////////////////////////
30 | void SSLImp::destroy()
31 | {
32 | //destroy servant here:
33 | //...
34 | }
35 |
36 | int SSLImp::testHello(const std::string &sReq, std::string &sRsp, tars::TarsCurrentPtr current)
37 | {
38 | // TLOGDEBUG("SSLImp::testHellosReq:"<
21 | #include "servant/Application.h"
22 |
23 | using namespace tars;
24 |
25 | /**
26 | *
27 | **/
28 | class SSLServer : public Application
29 | {
30 | public:
31 | /**
32 | *
33 | **/
34 | virtual ~SSLServer() {};
35 |
36 | /**
37 | *
38 | **/
39 | virtual void initialize();
40 |
41 | /**
42 | *
43 | **/
44 | virtual void destroyApp();
45 | };
46 |
47 | extern SSLServer g_app;
48 |
49 | ////////////////////////////////////////////
50 | #endif
51 |
--------------------------------------------------------------------------------
/examples/SSLDemo/Server/ssl.tars:
--------------------------------------------------------------------------------
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 | module TestApp
18 | {
19 |
20 | interface Hello
21 | {
22 | int test();
23 | int testHello(string sReq, out string sRsp);
24 | };
25 |
26 | };
27 |
--------------------------------------------------------------------------------
/examples/SSLDemo/certs/ca.crt:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIIDCzCCAfOgAwIBAgIUblg0MMUtu1YdIF1CmdlcKCXdg5gwDQYJKoZIhvcNAQEL
3 | BQAwFTETMBEGA1UEAwwKKi5kZW1vLmNvbTAeFw0yMDAyMTQxMjQ5MDVaFw0zMzEw
4 | MjMxMjQ5MDVaMBUxEzARBgNVBAMMCiouZGVtby5jb20wggEiMA0GCSqGSIb3DQEB
5 | AQUAA4IBDwAwggEKAoIBAQCv8i3rLGi7j1E62fvpZ+9DI0kz6ASNOrmphzHS/E9p
6 | X7EijiLpat+YARsYC42qA4+Cky1ItDTASUAkvVZNCj+6TNsFx1LSesgE28roOBOi
7 | qXCtwBIQvAJBPRpgZtX5++BWyxexBsHszp8t1k7QKgVY3eXeGCQHOHZZltXNFGKP
8 | 2hruxct2VEcZWqWdYKE1hy0GSyxvejsT2GLv2OMlWwD/iE+UvTKU5+9CTq/vfx3j
9 | vGUo410DniMz1OqqxAAamKhx4lzKvPfZeW/CQe929qwQONxGQENRXKiCiPkMTRIo
10 | JCdXBDS6ztolq4URIB57yCq88qMO8ZY6URA6U97qyhlJAgMBAAGjUzBRMB0GA1Ud
11 | DgQWBBSAwN6/0NtVoAWC7TB9PnYMzJhMJTAfBgNVHSMEGDAWgBSAwN6/0NtVoAWC
12 | 7TB9PnYMzJhMJTAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBX
13 | rGw19azPpFebPM5WHOUNBF5CesevnE4md0lE/9DcXl1wSLAwJC7bVijqt/gA4AgO
14 | i+7AnVxlrrMZ4UBEgMu8cHyAGuaC/u+wSJ49TpciMk3/bKfN1gnQ1O/bzm8zpP/B
15 | zQmffhiQcuM1wqStQeTnqD7bP4vAQKqLZGb0Hca2dPsRYIgW+z1dxLg6dxrFlkG8
16 | dunwDDQXsnYf3PcB2fMQuK1lJltiiu7sVe+XeFeRTFSDGyxDs9q28SwRIHWlzIIC
17 | j+57DkNAgBf9aYf7QM2dnmFNMHSs9fP8MZX7kltu5GadJKprDbjBtJd4IWSCMOv5
18 | A/fdjurUkf3aCj1qGj+o
19 | -----END CERTIFICATE-----
20 |
--------------------------------------------------------------------------------
/examples/SSLDemo/certs/ca.srl:
--------------------------------------------------------------------------------
1 | 5C1561567852EF51D268687494029145127A56C7
2 |
--------------------------------------------------------------------------------
/examples/SSLDemo/certs/client.crt:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIICsTCCAZkCFFwVYVZ4Uu9R0mhodJQCkUUSelbFMA0GCSqGSIb3DQEBCwUAMBUx
3 | EzARBgNVBAMMCiouZGVtby5jb20wHhcNMjAwMjE0MTI0OTA2WhcNMzMxMDIzMTI0
4 | OTA2WjAVMRMwEQYDVQQDDAoqLmRlbW8uY29tMIIBIjANBgkqhkiG9w0BAQEFAAOC
5 | AQ8AMIIBCgKCAQEAzXLpEt1TWXzwWx6eQPGztqo7MSx8r3vxh5l5Wm45tRTNXot8
6 | eh7QWvJChflUlnz9y0J7O2SxFnjdpHrp29AkLlt/aRjvRfLfgDcc7LqfUpWcc3qz
7 | bkYPnktywXAuA1R3JnnsrDKFiwPY5Fc0bVuiZ0VZD9ufalvoc+kd3PjeQYvYkvUa
8 | axZ0iaxKs5PaKwYIKW7RsWQa2bNkArH+slet50JDbDXuZXEnPghBLyjAhkhPmLQ8
9 | jjrMX1t4fl0qQ21/q7TDf4FL+QNTcmEWQFEpz2H3qhM+J8UU2JdW36p+++Nj3CaF
10 | lcWpCpxqJ8UGMqCfTM+KcPmBg/UQ/ByRb0wiqwIDAQABMA0GCSqGSIb3DQEBCwUA
11 | A4IBAQBMED94VcdZJwznIJ3FOyv+8D7P9PYS1KvIVclsC1G2Wzrhohx4sMcCE4QE
12 | 43TJDc0Vj/fQR+g3IyPL3TTWofLuif/Pp+7t2mieST7USrIWPJuUYYdkbch/WUEX
13 | +p9vzdKJOnClCcdcMIptUJdHd7/X+qHPo0m4xg8qEfkW79IvcOQqAcl0Mx+Lxiny
14 | Xps3VTe7j6IOdv4ZycD0OtYj3RSoQPfjWZ8yFV7riYjd0hj05sG/CNJ/9Nvy34tn
15 | xRZnlWzMziOqYK+U/2BS1+j+LrfMJCgeShGdmBziqMde99Vovj2dv7sDvXqfZfCz
16 | jLWfPO5ShCU72n7MoM/yqsTD8FmS
17 | -----END CERTIFICATE-----
18 |
--------------------------------------------------------------------------------
/examples/SSLDemo/certs/client.csr:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE REQUEST-----
2 | MIICWjCCAUICAQAwFTETMBEGA1UEAwwKKi5kZW1vLmNvbTCCASIwDQYJKoZIhvcN
3 | AQEBBQADggEPADCCAQoCggEBAM1y6RLdU1l88FsenkDxs7aqOzEsfK978YeZeVpu
4 | ObUUzV6LfHoe0FryQoX5VJZ8/ctCeztksRZ43aR66dvQJC5bf2kY70Xy34A3HOy6
5 | n1KVnHN6s25GD55LcsFwLgNUdyZ57KwyhYsD2ORXNG1bomdFWQ/bn2pb6HPpHdz4
6 | 3kGL2JL1GmsWdImsSrOT2isGCClu0bFkGtmzZAKx/rJXredCQ2w17mVxJz4IQS8o
7 | wIZIT5i0PI46zF9beH5dKkNtf6u0w3+BS/kDU3JhFkBRKc9h96oTPifFFNiXVt+q
8 | fvvjY9wmhZXFqQqcaifFBjKgn0zPinD5gYP1EPwckW9MIqsCAwEAAaAAMA0GCSqG
9 | SIb3DQEBCwUAA4IBAQCG6KZeU22DzRgfoljtuyPNuONyBPLsDbT2nhM8UFNS7Io9
10 | hJYIn5FA57PC6vfJOPW4lvg5c73pjccJlLMYzPZ/TwvxUwcQzjeebZeRpPCB2fgQ
11 | ihX/6pyN0s2Li2WK8dNq02y0bH+f+ItftCoFnrhJPfNxObaSpNQh7rIbkxujOprG
12 | wqPmVFvEydzPwFwe6O42b2Ame+qdjva9QH4nbd8dG47kKCVhP8CMq8UbMvngVcbn
13 | 9A5dg4mS3OnTAdR21bNlZGQVHTiojKd3go7KrFwMlcRrCZ63+M510wIpUBxmFClA
14 | icfaUazi62EikDnnFExu60xQ8MpWL9U57foKV8ci
15 | -----END CERTIFICATE REQUEST-----
16 |
--------------------------------------------------------------------------------
/examples/SSLDemo/certs/client1.crt:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIICsTCCAZkCFFwVYVZ4Uu9R0mhodJQCkUUSelbHMA0GCSqGSIb3DQEBCwUAMBUx
3 | EzARBgNVBAMMCiouZGVtby5jb20wHhcNMjAwMjE0MTI0OTA2WhcNMzMxMDIzMTI0
4 | OTA2WjAVMRMwEQYDVQQDDAoqLmRlbW8uY29tMIIBIjANBgkqhkiG9w0BAQEFAAOC
5 | AQ8AMIIBCgKCAQEA7Qw+OBtzkGG38r4IOBzgpJte5qHPCTBCeowt/6dmwY3W+1bU
6 | cf5wdHBtSsuv3M5OpWKCG8gu3gpBZQvpz7MfN50ouuM0sDvKUxIUP2KX/nv7uiDg
7 | R4iJy47M4XSH2qbRovKPZeRCeigkiU4gKMnJ0Vx82EgEdOLzBt1wLL8a0q1zVOwC
8 | stII/0d4VhCoWgurddJa1gU7EwQ+ZRLwSbbvtgsEfVYCvwC/gb3fGrljJ2PpeY2/
9 | UfxggnqGcG0IZoT4zi0uyRgK094nPVupS9JM5ig4I/FpP+KQ1LTlDh9LrwZrCQXj
10 | /DFp0Wka5DWHTXWb7TwZShFo3r3emD3gGZi0owIDAQABMA0GCSqGSIb3DQEBCwUA
11 | A4IBAQB9+YqEgsabF3hh3OBFZmg0Je12mkFBsMCRPwMOXfEY8Mzt7xVHHx5iKsBa
12 | u3XaLhVnOgu6VryGSIRmD7lGMctfIELysWu5xQtoY+m9xWZfDhY8G9sNhLSShJ/H
13 | 7UZ5/FUi+meohIM0SHEdzTyQtBSs+lfhgshsgtpZ4ysZDQTM/ukuOyBf1vXcs+Gx
14 | pQa4hDQ+Tnev0h6z4PIDCeg88KohDgrzFMSFZ04bNUSLeIxjgo47hLxVNa/3xokh
15 | yaTz4QZ3OcOjjfw//5lyfLDAZ7Rk1FBZ+NjdGRPjmTVIic2utT4QwS8aQyqDN/jA
16 | gxo1xb+Tu5YxHXkMGa2hwV3VvhkF
17 | -----END CERTIFICATE-----
18 |
--------------------------------------------------------------------------------
/examples/SSLDemo/certs/client1.csr:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE REQUEST-----
2 | MIICWjCCAUICAQAwFTETMBEGA1UEAwwKKi5kZW1vLmNvbTCCASIwDQYJKoZIhvcN
3 | AQEBBQADggEPADCCAQoCggEBAO0MPjgbc5Bht/K+CDgc4KSbXuahzwkwQnqMLf+n
4 | ZsGN1vtW1HH+cHRwbUrLr9zOTqVighvILt4KQWUL6c+zHzedKLrjNLA7ylMSFD9i
5 | l/57+7og4EeIicuOzOF0h9qm0aLyj2XkQnooJIlOICjJydFcfNhIBHTi8wbdcCy/
6 | GtKtc1TsArLSCP9HeFYQqFoLq3XSWtYFOxMEPmUS8Em277YLBH1WAr8Av4G93xq5
7 | Yydj6XmNv1H8YIJ6hnBtCGaE+M4tLskYCtPeJz1bqUvSTOYoOCPxaT/ikNS05Q4f
8 | S68GawkF4/wxadFpGuQ1h011m+08GUoRaN693pg94BmYtKMCAwEAAaAAMA0GCSqG
9 | SIb3DQEBCwUAA4IBAQDrJMiKZIriezIo2PaJzm1Da4vcB41oiFVQGZuFRRN7Mt9t
10 | tMDuZeVILSqkT1zHu0lamGuS/SKk1VSV0Or7S5Y2Bzm6MtsbVSpbMsRSj9HvXhZJ
11 | lC6+YV1BfiZdSLdWPh/0vn6ku6/znKl8o68DvZyvSDoBahafbQluab/KGf85B0JP
12 | vJ0AHAokfGMiragnKfJhPO18+IT5OClDDdjXbVs/PWx0SLt1EHjzqJOTNtvpDIw+
13 | BZIiOcxhz7UjnGeyp5dvpnEbmhmk0WhZ0tsP2czOQwZIDesx2Nhbz/V45X1qDU3O
14 | W0K9g37n7m1zsWHlA7LXwpSzG+wJTRWMOVGUxfyg
15 | -----END CERTIFICATE REQUEST-----
16 |
--------------------------------------------------------------------------------
/examples/SSLDemo/certs/server.crt:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIICsTCCAZkCFFwVYVZ4Uu9R0mhodJQCkUUSelbEMA0GCSqGSIb3DQEBCwUAMBUx
3 | EzARBgNVBAMMCiouZGVtby5jb20wHhcNMjAwMjE0MTI0OTA1WhcNMzMxMDIzMTI0
4 | OTA1WjAVMRMwEQYDVQQDDAoqLmRlbW8uY29tMIIBIjANBgkqhkiG9w0BAQEFAAOC
5 | AQ8AMIIBCgKCAQEAwLHEXgjzTX6Z7MvPI1IAgwiEGuFyPl8b8o/tY9+2mvvs7EU4
6 | oK3DDRFoGwkTGfuLwstuhKllE2QyIr5QN6FmfWWiitjOovlEVRTJ5a274YXes9Kz
7 | uFlw6RT9WDj2iEkgdB7KWfQjaoCWrjhNt1rzh/jRpcmHsLmpOiQYBPeIpqVTnK1o
8 | risQ6352qnmperB8lcj731rKebDwZIo9y5nL/qDzwH3dBJQeFqvNuPcSd76lrpy+
9 | 9GTA3lFgQQJyUiSwzBD005LKKW4fEcdllPa+/jLAuKO/atm+6dv186w7ojIMceir
10 | 549jn9UUyvWXfSfXl+68Aku1FTFFhRdS6OMsWQIDAQABMA0GCSqGSIb3DQEBCwUA
11 | A4IBAQCLCr8rsrgZskc3Ou7dZ5Br8xA2m7lrLSkFQIsDRosfBPerhGr83mgeyp2+
12 | DNbPy0+IzgBUyN8N/P3QlZbQFq/3u9bjih3QukJuJe6KfYI0/iQu5jHxFv7VgbE+
13 | a8yqUsrirWsmpltOMobv19jtWm/v1kofvCIUSBCJXkVi2L75164MhkKTGbSV1dl/
14 | Ujg+X9yss5ZcDR+MqzuHZOO9580Ky0p+9m+STpZFG7QvC9QQtbvUBogAWECg+sSB
15 | RQ7Maq337ERpJg5EGOG2R+sa8rssMGFMRJ9OfenS+KaRF/oNKKL12pG7Y+oYpfEj
16 | WfSt4Lv16RWdV2vkmrorTovSuTIa
17 | -----END CERTIFICATE-----
18 |
--------------------------------------------------------------------------------
/examples/SSLDemo/certs/server.csr:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE REQUEST-----
2 | MIICWjCCAUICAQAwFTETMBEGA1UEAwwKKi5kZW1vLmNvbTCCASIwDQYJKoZIhvcN
3 | AQEBBQADggEPADCCAQoCggEBAMCxxF4I801+mezLzyNSAIMIhBrhcj5fG/KP7WPf
4 | tpr77OxFOKCtww0RaBsJExn7i8LLboSpZRNkMiK+UDehZn1loorYzqL5RFUUyeWt
5 | u+GF3rPSs7hZcOkU/Vg49ohJIHQeyln0I2qAlq44Tbda84f40aXJh7C5qTokGAT3
6 | iKalU5ytaK4rEOt+dqp5qXqwfJXI+99aynmw8GSKPcuZy/6g88B93QSUHharzbj3
7 | Ene+pa6cvvRkwN5RYEECclIksMwQ9NOSyiluHxHHZZT2vv4ywLijv2rZvunb9fOs
8 | O6IyDHHoq+ePY5/VFMr1l30n15fuvAJLtRUxRYUXUujjLFkCAwEAAaAAMA0GCSqG
9 | SIb3DQEBCwUAA4IBAQBLD12Bwb5YZE0PSLMm37/KMoN1nl1bug002HXGjtK48I+J
10 | 8pyd4BX5yW69gIP/CeHouDqJ/vhTdJmm/mLsexcby21RW55XYouCGLT/Cmh5qj+K
11 | HmcMR6lo38Q324cjNaMiqX8yAthbfWIC2Wupzb69SUiaXqXZ7F5dC+tB8DSVEvIY
12 | LBwxcXQBHC4C4k5aCIaPTlA20wdT0CKmD914Jby+iP5HP64nvc5yxacjKO+uOwNB
13 | AZe/uLWeCJs6v372oiFaiN+m8EQhmcD/2i8qSiFCcC3V3MRAZitoJseaYnRR9Aev
14 | wYCI6lpn2nCdM/L0+uOxZ2sA3hkb2muoUSPaRLq/
15 | -----END CERTIFICATE REQUEST-----
16 |
--------------------------------------------------------------------------------
/examples/SSLDemo/certs/server1.crt:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIICsTCCAZkCFFwVYVZ4Uu9R0mhodJQCkUUSelbGMA0GCSqGSIb3DQEBCwUAMBUx
3 | EzARBgNVBAMMCiouZGVtby5jb20wHhcNMjAwMjE0MTI0OTA2WhcNMzMxMDIzMTI0
4 | OTA2WjAVMRMwEQYDVQQDDAoqLmRlbW8uY29tMIIBIjANBgkqhkiG9w0BAQEFAAOC
5 | AQ8AMIIBCgKCAQEA3o5I31gvK3AiF0sFAtHSt1diLMZEG1JtkeaKm9lIQgzqdG8+
6 | f2nZPVAvU66M3B6uiYMU/QQVh3KAXF5bMyKhJtLGNYHqj6VoJatvWVdb1iasQW9M
7 | 8eGl2exxDMTPHWJ44vOYLcXJ6M3WRcfIXHC9K3rIjz2bWjDqHU8Y0fecCSJX8ctR
8 | gxgNBwM41P45dExbxQp5RGye7TOfXnf0yQJReFx2JDzzYqQ61VoqlkTw2RkuSr0Q
9 | ydr8S7CuReWF0xbKzMGf1L+SzmyGB2SAc9jkJ7T3Y4B36iy3y8hvMBTbCmke4ZpO
10 | FDrTw95wfC611nTXNKjUOlulKxSf+cfhACPFWwIDAQABMA0GCSqGSIb3DQEBCwUA
11 | A4IBAQCpQEXaFJiXSLeL9HKnvIexlxWfjTvikMoNR0t3UMxShazKE5gkQSw3WtCo
12 | E+LmmDvt0bqn54fk77oWxwZTx/qe8vJwpo0/gl/tNnGnzdzIAXk10G1W7kWkU2eG
13 | gpvYcQXKpW0QORHRzEXMbGIzdqjZOaFZYA+VtbtFB0cSLx8eNtd/bKxtwZyl66es
14 | uhPF40TnH6ccyq0Z2WuQylG4aSZ7qQcxCJUKj/Ych1+wr45ncgTZIsKXPBd0k7Kx
15 | xYvEuW8WGSjpJD8qPXt8hEwWpOfwLsmpnF1kMyaONLSHcqhfNU0bPTolLUSDJxkY
16 | 0JVVfeStdEsrmos1SrpEjD+wGlng
17 | -----END CERTIFICATE-----
18 |
--------------------------------------------------------------------------------
/examples/SSLDemo/certs/server1.csr:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE REQUEST-----
2 | MIICWjCCAUICAQAwFTETMBEGA1UEAwwKKi5kZW1vLmNvbTCCASIwDQYJKoZIhvcN
3 | AQEBBQADggEPADCCAQoCggEBAN6OSN9YLytwIhdLBQLR0rdXYizGRBtSbZHmipvZ
4 | SEIM6nRvPn9p2T1QL1OujNweromDFP0EFYdygFxeWzMioSbSxjWB6o+laCWrb1lX
5 | W9YmrEFvTPHhpdnscQzEzx1ieOLzmC3FyejN1kXHyFxwvSt6yI89m1ow6h1PGNH3
6 | nAkiV/HLUYMYDQcDONT+OXRMW8UKeURsnu0zn1539MkCUXhcdiQ882KkOtVaKpZE
7 | 8NkZLkq9EMna/EuwrkXlhdMWyszBn9S/ks5shgdkgHPY5Ce092OAd+ost8vIbzAU
8 | 2wppHuGaThQ608PecHwutdZ01zSo1DpbpSsUn/nH4QAjxVsCAwEAAaAAMA0GCSqG
9 | SIb3DQEBCwUAA4IBAQBUY5PIac76NGf+rHFG0xAXrZDuttwJOUjywz0La//+iPPK
10 | RFm+x+LK5tLc6Iunfo3Po7BedISIQ1+QxA8l2x6SmEczrJxGolwgjkj4iozhL5m+
11 | UKbsKF6V+3ZF7wHcbVZ9dCQsr6dO39Qg4x07U0DUDll4L3bk7cMyZBX2WAq3Tp6u
12 | jBJI96A8VcnVs0lTghQNfJlGBv6OFPXJPHpgJucZ/e4Kpbr/bMxVF/bRRoEaNz1G
13 | 1JbieeB4Ohv0P3SzYTj4zgOYV1NTizg1a7SeODFJ3uDtGm2oN3TAzE6yg3ngzxvk
14 | u+F5d+KbhSewBe/AuAWIK1Jn1Ez3NGMoR5zMbKCg
15 | -----END CERTIFICATE REQUEST-----
16 |
--------------------------------------------------------------------------------
/examples/StressDemo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | include_directories(TarsStressServer)
3 | add_subdirectory(TarsStressServer)
4 | add_subdirectory(TarsStressClient)
5 |
6 |
--------------------------------------------------------------------------------
/examples/StressDemo/README.md:
--------------------------------------------------------------------------------
1 | 该工程是Tars入门示例的代码
2 |
3 |
4 | 目录名称 |功能
5 | -----------------|----------------
6 | TarsStressServer | Tars性能压测服务端的程序
7 | TarsStressClient | Tars性能压测客户端的程序
8 |
--------------------------------------------------------------------------------
/examples/StressDemo/TarsStressClient/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("TarsStressClient" "TarsStressServer")
--------------------------------------------------------------------------------
/examples/StressDemo/TarsStressClient/teststress.sh:
--------------------------------------------------------------------------------
1 | # Language: bash
2 | for((i=1; i<=$1; i++)); do {
3 | ./TarsStressClient $2 1500000 Test.StressServer.StressObj $3
4 | } & done
5 | wait
6 |
--------------------------------------------------------------------------------
/examples/StressDemo/TarsStressServer/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("TarsStressServer" "")
--------------------------------------------------------------------------------
/examples/StressDemo/TarsStressServer/Stress.tars:
--------------------------------------------------------------------------------
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 | module Test
18 | {
19 |
20 | interface Stress
21 | {
22 | int test();
23 | int testStr(string sIn, out string sOut);
24 | };
25 |
26 | };
27 |
--------------------------------------------------------------------------------
/examples/StressDemo/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 |
--------------------------------------------------------------------------------
/examples/UdpDemo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | include_directories(Server)
3 | add_subdirectory(Server)
4 | add_subdirectory(Client)
5 |
6 |
--------------------------------------------------------------------------------
/examples/UdpDemo/Client/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server(UdpClient UdpServer)
2 |
--------------------------------------------------------------------------------
/examples/UdpDemo/Client/config.conf:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | #tarsregistry locator
6 | locator = tars.tarsregistry.QueryObj@tcp -h 127.0.0.1 -p 17890
7 | #max invoke timeout
8 | sync-invoke-timeout = 5000
9 | #refresh endpoint interval
10 | refresh-endpoint-interval = 10000
11 | #stat obj
12 | stat = tars.tarsstat.StatObj
13 | #max send queue length limit
14 | sendqueuelimit = 100000
15 | #async queue length limit
16 | asyncqueuecap = 100000
17 | #async callback thread num
18 | asyncthread = 3
19 | #net thread
20 | netthread = 1
21 | #merge net and sync thread
22 | mergenetasync = 0
23 | #module name
24 | modulename = TestApp.UdpClient
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/examples/UdpDemo/Server/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | build_tars_server("UdpServer" "")
2 |
3 |
--------------------------------------------------------------------------------
/examples/UdpDemo/Server/Hello.tars:
--------------------------------------------------------------------------------
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 | module TestApp
18 | {
19 |
20 | interface Hello
21 | {
22 | int test();
23 | int testHello(string sReq, out string sRsp);
24 | };
25 |
26 | };
27 |
--------------------------------------------------------------------------------
/examples/UdpDemo/Server/HelloImp.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 "HelloImp.h"
18 | #include "servant/Application.h"
19 |
20 | using namespace std;
21 |
22 | //////////////////////////////////////////////////////
23 | void HelloImp::initialize()
24 | {
25 | //initialize servant here:
26 | //...
27 | }
28 |
29 | //////////////////////////////////////////////////////
30 | void HelloImp::destroy()
31 | {
32 | //destroy servant here:
33 | //...
34 | }
35 |
36 | int HelloImp::testHello(const std::string &sReq, std::string &sRsp, tars::TarsCurrentPtr current)
37 | {
38 | // TLOGDEBUG("HelloImp::testHellosReq:"<
21 | #include "servant/Application.h"
22 |
23 | using namespace tars;
24 |
25 | /**
26 | *
27 | **/
28 | class HelloServer : public Application
29 | {
30 | public:
31 | /**
32 | *
33 | **/
34 | virtual ~HelloServer() {};
35 |
36 | /**
37 | *
38 | **/
39 | virtual void initialize();
40 |
41 | /**
42 | *
43 | **/
44 | virtual void destroyApp();
45 | };
46 |
47 | extern HelloServer g_app;
48 |
49 | ////////////////////////////////////////////
50 | #endif
51 |
--------------------------------------------------------------------------------
/examples/UtilDemo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | add_subdirectory(demo-server)
3 | add_subdirectory(demo-util)
4 |
5 |
--------------------------------------------------------------------------------
/examples/UtilDemo/demo-server/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | include_directories(${util_SOURCE_DIR}/include)
2 |
3 | FILE(GLOB_RECURSE SRC_LIST "*.cpp")
4 |
5 | if (TARS_SSL)
6 | if (WIN32)
7 | link_libraries(tarsutil ${LIB_SSL} ${LIB_CRYPTO} Crypt32)
8 | else ()
9 | link_libraries(tarsutil ${LIB_SSL} ${LIB_CRYPTO})
10 | endif ()
11 | else ()
12 | link_libraries(tarsutil)
13 | endif ()
14 |
15 | add_executable(demo-server ${SRC_LIST})
16 |
17 | add_dependencies(demo-server tarsutil)
18 |
19 |
--------------------------------------------------------------------------------
/examples/UtilDemo/demo-util/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | include_directories(${util_SOURCE_DIR}/include)
2 | include_directories(${CMAKE_BINARY_DIR}/src/gtest/include)
3 | link_directories(${CMAKE_BINARY_DIR}/src/gtest/lib)
4 | link_directories(${CMAKE_BINARY_DIR}/src/gtest/lib64)
5 |
6 | FILE(GLOB_RECURSE SRC_LIST "*.cpp")
7 |
8 | if (TARS_SSL)
9 | if (WIN32)
10 | link_libraries(tarsutil ${LIB_GTEST} ${LIB_SSL} ${LIB_CRYPTO} Crypt32)
11 | else ()
12 | link_libraries(tarsutil ${LIB_GTEST} ${LIB_SSL} ${LIB_CRYPTO})
13 | endif ()
14 | else ()
15 | link_libraries(tarsutil ${LIB_GTEST})
16 | endif ()
17 |
18 | add_executable(demo-util ${SRC_LIST})
19 |
20 | add_dependencies(demo-util tarsutil)
21 |
22 |
23 |
--------------------------------------------------------------------------------
/examples/UtilDemo/demo-util/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include "gtest/gtest.h"
5 |
6 | using namespace std;
7 |
8 | int main(int argc, char** argv)
9 | {
10 | testing::InitGoogleTest(&argc, argv);
11 | return RUN_ALL_TESTS();
12 | }
--------------------------------------------------------------------------------
/examples/UtilDemo/demo-util/test_tc_encoder.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by jarod on 2020/2/20.
3 | //
4 |
5 | #include "util/tc_encoder.h"
6 | #include "gtest/gtest.h"
7 | #include "util/tc_common.h"
8 |
9 | using namespace tars;
10 |
11 | class EncodeTest : public testing::Test
12 | {
13 | public:
14 | //添加日志
15 | static void SetUpTestCase()
16 | {
17 | }
18 | static void TearDownTestCase()
19 | {
20 | }
21 | virtual void SetUp() //TEST跑之前会执行SetUp
22 | {
23 | }
24 | virtual void TearDown() //TEST跑完之后会执行TearDown
25 | {
26 | }
27 | };
28 |
29 | TEST_F(EncodeTest, encode)
30 | {
31 | string utf8="我们的祖国;";
32 | string gbk;
33 |
34 | gbk = TC_Encoder::utf82gbk(utf8);//, TC_Encoder::ICONV_NORMAL);
35 |
36 | string tmpUtf8 = TC_Encoder::gbk2utf8(gbk);//, TC_Encoder::ICONV_NORMAL);
37 |
38 | ASSERT_TRUE(utf8 == tmpUtf8);
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/examples/scripts/run-auth.bat:
--------------------------------------------------------------------------------
1 |
2 | echo "run-auth.bat"
3 |
4 | set EXE_PATH=%1
5 | set SRC_PATH=%2\\..
6 |
7 | echo %EXE_PATH% %SRC_PATH%
8 |
9 | taskkill /im AuthServer.exe /t /f
10 |
11 | timeout /T 1
12 |
13 | echo "start server: %EXE_PATH%/AuthServer.exe --config=%SRC_PATH%/examples/AuthDemo/Server/config.conf"
14 |
15 | start /b %EXE_PATH%\\AuthServer.exe --config=%SRC_PATH%\\examples\\AuthDemo\\Server\\config.conf
16 |
17 | timeout /T 3
18 |
19 | echo "client: ${EXE_PATH}/AuthClient.exe"
20 |
21 | %EXE_PATH%\\AuthClient.exe --count=10000 --thread=2 --call=sync --buffersize=1000 --netthread=1
22 | %EXE_PATH%\\AuthClient.exe --count=10000 --thread=2 --call=async --buffersize=1000 --netthread=1
23 |
24 | timeout /T 1
25 |
26 | taskkill /im AuthServer.exe /t /f
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/examples/scripts/run-auth.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo "run-auth.sh"
4 |
5 | EXE_PATH=$1
6 | SRC_PATH=$2/..
7 |
8 | echo ${EXE_PATH} ${SRC_PATH}
9 |
10 | killall -9 AuthServer
11 |
12 | sleep 1
13 | echo "start server: ${EXE_PATH}/AuthServer --config=${SRC_PATH}/examples/AuthDemo/Server/config.conf &"
14 |
15 | ${EXE_PATH}/AuthServer --config=${SRC_PATH}/examples/AuthDemo/Server/config.conf &
16 |
17 | sleep 1
18 |
19 | echo "client: ${EXE_PATH}/AuthClient"
20 |
21 | ${EXE_PATH}/AuthClient --config=${SRC_PATH}/examples/AuthDemo/Client/config.conf --count=10000 --thread=2 --call=sync --buffersize=1000 --netthread=1
22 | ${EXE_PATH}/AuthClient --config=${SRC_PATH}/examples/AuthDemo/Client/config.conf --count=10000 --thread=2 --call=async --buffersize=1000 --netthread=1
23 |
24 | sleep 1
25 |
26 | killall -9 AuthServer
27 |
28 |
29 |
--------------------------------------------------------------------------------
/examples/scripts/run-custom.bat:
--------------------------------------------------------------------------------
1 |
2 | echo "run-push.bat"
3 |
4 | set EXE_PATH=%1
5 | set SRC_PATH=%2\\..
6 |
7 | echo %EXE_PATH% %SRC_PATH%
8 |
9 | taskkill /im CustomServer.exe /t /f
10 |
11 | timeout /T 1
12 |
13 | echo "start server: %EXE_PATH%\\CustomServer.exe --config=%SRC_PATH%\\examples\\CustomDemo\\CustomServer\\config.conf "
14 |
15 | start /b %EXE_PATH%\\CustomServer.exe --config=%SRC_PATH%\\examples\\CustomDemo\\CustomServer\\config.conf
16 |
17 | timeout /T 1
18 |
19 | ::-------------------------------------------------------------------------------------------------------
20 |
21 | echo "client: %EXE_PATH%\\CustomClient.exe"
22 |
23 | %EXE_PATH%\\CustomClient.exe --count=10000 --thread=2 --call=sync --netthread=2 --buffersize=100
24 | %EXE_PATH%\\CustomClient.exe --count=10000 --thread=2 --call=async --netthread=2 --buffersize=100
25 |
26 | taskkill /im CustomServer.exe /t /f
27 |
28 |
--------------------------------------------------------------------------------
/examples/scripts/run-custom.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo "run-custom.sh"
4 |
5 | EXE_PATH=$1
6 | SRC_PATH=$2/..
7 |
8 | echo ${EXE_PATH} ${SRC_PATH}
9 |
10 | killall -9 CustomServer
11 |
12 | sleep 1
13 | echo "start server: ${EXE_PATH}/CustomServer --config=${SRC_PATH}/examples/CustomDemo/CustomServer/config.conf &"
14 |
15 | ${EXE_PATH}/CustomServer --config=${SRC_PATH}/examples/CustomDemo/CustomServer/config.conf &
16 |
17 | sleep 2
18 |
19 | #-------------------------------------------------------------------------------------------------------
20 |
21 | echo "client: ${EXE_PATH}/CustomClient"
22 |
23 | ${EXE_PATH}/CustomClient --count=10000 --thread=2 --call=sync --netthread=1 --buffersize=100
24 |
25 | ${EXE_PATH}/CustomClient --count=10000 --thread=2 --call=async --netthread=1 --buffersize=100
26 |
27 | killall -9 CustomServer
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/examples/scripts/run-http.bat:
--------------------------------------------------------------------------------
1 |
2 | echo "run-http.bat"
3 |
4 | set EXE_PATH=%1
5 | set SRC_PATH=%2\\..
6 |
7 | echo %EXE_PATH% %SRC_PATH%
8 |
9 | taskkill /im HttpServer.exe /t /f
10 |
11 | timeout /T 1
12 |
13 | echo "start server: ${EXE_PATH}/HttpServer.exe --config=%SRC_PATH%/examples/HttpDemo/HttpServer/config.conf"
14 |
15 | start /b %EXE_PATH%\\HttpServer.exe --config=%SRC_PATH%\\examples\\HttpDemo\\HttpServer\\config.conf
16 |
17 | timeout /T 3
18 |
19 | echo "client: ${EXE_PATH}/HttpClient.exe"
20 |
21 | %EXE_PATH%\\HttpClient.exe --count=10000 --thread=2 --call=basehttp
22 |
23 | timeout /T 1
24 |
25 | taskkill /im HttpServer.exe /t /f
26 |
27 |
28 |
--------------------------------------------------------------------------------
/examples/scripts/run-http.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo "run-http.sh"
4 |
5 | EXE_PATH=$1
6 | SRC_PATH=$2/..
7 |
8 | echo ${EXE_PATH} ${SRC_PATH}
9 |
10 | killall -9 HttpServer
11 |
12 | sleep 1
13 | echo "start server: ${EXE_PATH}/HttpServer --config=${SRC_PATH}/examples/HttpDemo/HttpServer/config.conf &"
14 |
15 | ${EXE_PATH}/HttpServer --config=${SRC_PATH}/examples/HttpDemo/HttpServer/config.conf &
16 |
17 | sleep 1
18 |
19 | echo "client: ${EXE_PATH}/HttpClient"
20 |
21 | ${EXE_PATH}/HttpClient --count=10000 --thread=2 --call=base
22 | ${EXE_PATH}/HttpClient --count=10000 --thread=2 --call=sync
23 | ${EXE_PATH}/HttpClient --count=10000 --thread=2 --call=async
24 | #${EXE_PATH}/HttpClient --count=10000 --thread=2 --call=synchttp
25 |
26 | sleep 1
27 |
28 | killall -9 HttpServer
29 |
30 |
31 |
--------------------------------------------------------------------------------
/examples/scripts/run-http2.bat:
--------------------------------------------------------------------------------
1 |
2 | echo "run-http2.bat"
3 |
4 | set EXE_PATH=%1
5 | set SRC_PATH=%2\\..
6 |
7 | echo %EXE_PATH% %SRC_PATH%
8 |
9 | taskkill /im Http2Server.exe /t /f
10 |
11 | timeout /T 1
12 |
13 | echo "start server: %EXE_PATH%\\Http2Server.exe --config=%SRC_PATH%\\examples\\HttpDemo\\Http2Server\\config.conf "
14 |
15 | start /b %EXE_PATH%\\Http2Server.exe --config=%SRC_PATH%\\examples\\HttpDemo\\Http2Server\\config.conf
16 |
17 | timeout /T 3
18 |
19 | echo "client: %EXE_PATH%\\Http2Client.exe"
20 |
21 | %EXE_PATH%\\Http2Client.exe --count=10000 --thread=2 --call=sync
22 | %EXE_PATH%\\Http2Client.exe --count=10000 --thread=2 --call=async
23 |
24 | timeout /T 1
25 |
26 | taskkill /im Http2Server.exe /t /f
27 |
28 |
29 |
--------------------------------------------------------------------------------
/examples/scripts/run-http2.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo "run-http2.sh"
4 | EXE_PATH=$1
5 | SRC_PATH=$2/..
6 |
7 | echo ${EXE_PATH} ${SRC_PATH}
8 |
9 | killall -9 Http2Server
10 |
11 | sleep 1
12 | echo "start server: ${EXE_PATH}/Http2Server --config=${SRC_PATH}/examples/HttpDemo/Http2Server/config.conf &"
13 |
14 | ${EXE_PATH}/Http2Server --config=${SRC_PATH}/examples/HttpDemo/Http2Server/config.conf &
15 |
16 | sleep 1
17 |
18 | echo "client: ${EXE_PATH}/Http2Client"
19 |
20 | ${EXE_PATH}/Http2Client --count=10000 --thread=2 --call=async
21 | ${EXE_PATH}/Http2Client --count=10000 --thread=2 --call=sync
22 |
23 | sleep 1
24 |
25 | killall -9 Http2Server
26 |
27 |
28 |
--------------------------------------------------------------------------------
/examples/scripts/run-kill.bat:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo "run-kill.bat"
4 |
5 | taskkill /im SSLServer.exe /f
6 | taskkill /im AuthServer.exe /f
7 | taskkill /im CoroutineDemoAServer.exe /f
8 | taskkill /im CoroutineDemoBServer.exe /f
9 | taskkill /im CustomServer.exe /f
10 | taskkill /im HttpServer.exe /f
11 | taskkill /im Http2Server.exe /f
12 | taskkill /im PushServer.exe /f
13 | taskkill /im QuickStartDemo.exe /f
14 | taskkill /im ProxyServer.exe /f
15 | taskkill /im busybox.exe /f
16 |
17 | taskkill /im HttpClient.exe /f
18 | taskkill /im Http2Client.exe /f
19 | taskkill /im AuthClient.exe /f
20 | taskkill /im SSLClient.exe /f
21 | taskkill /im CoroutineDemoClient.exe /f
22 | taskkill /im testCoro.exe /f
23 | taskkill /im testParallelCoro.exe /f
24 | taskkill /im CustomClient.exe /f
25 | taskkill /im PushClient.exe /f
26 | taskkill /im QuickStartDemoClient.exe /f
--------------------------------------------------------------------------------
/examples/scripts/run-kill.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo "run-kill.sh"
4 |
5 | killall -9 SSLServer
6 | killall -9 AuthServer
7 | killall -9 CoroutineDemoAServer
8 | killall -9 CoroutineDemoBServer
9 | killall -9 CustomServer
10 | killall -9 HttpServer
11 | killall -9 Http2Server
12 | killall -9 PushServer
13 | killall -9 QuickStartDemo
14 | killall -9 ProxyServer
15 |
16 | killall -9 HttpClient
17 | killall -9 Http2Client
18 | killall -9 AuthClient
19 | killall -9 SSLClient
20 | killall -9 CoroutineDemoClient
21 | killall -9 testCoro
22 | killall -9 testParallelCoro
23 | killall -9 CustomClient
24 | killall -9 PushClient
25 | killall -9 QuickStartDemoClient
--------------------------------------------------------------------------------
/examples/scripts/run-push-callback.bat:
--------------------------------------------------------------------------------
1 |
2 | echo "run-push-callback.bat"
3 |
4 | set EXE_PATH=%1
5 | set SRC_PATH=%2\\..
6 |
7 | echo %EXE_PATH% %SRC_PATH%
8 |
9 | taskkill /im PushCallbackServer.exe /t /f
10 |
11 | timeout /T 1
12 |
13 | echo "start server: %EXE_PATH%/PushCallbackServer.exe --config=%SRC_PATH%/examples/PushCallbackDemo/Server/config.conf"
14 |
15 | start /b %EXE_PATH%\\PushCallbackServer.exe --config=%SRC_PATH%\\examples\\PushCallbackDemo\\Server\\config.conf
16 |
17 | timeout /T 3
18 |
19 | echo "client: ${EXE_PATH}/PushCallbackClient.exe"
20 |
21 | %EXE_PATH%\\PushCallbackClient.exe
22 |
23 | timeout /T 1
24 |
25 | taskkill /im PushCallbackServer.exe /t /f
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/examples/scripts/run-push-callback.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo "run-push-callback.sh"
4 |
5 | EXE_PATH=$1
6 | SRC_PATH=$2/..
7 |
8 | echo ${EXE_PATH} ${SRC_PATH}
9 |
10 | killall -9 PushCallbackServer
11 |
12 | sleep 1
13 | echo "start server: ${EXE_PATH}/PushCallbackServer --config=${SRC_PATH}/examples/PushCallbackDemo/Server/config.conf &"
14 |
15 | ${EXE_PATH}/PushCallbackServer --config=${SRC_PATH}/examples/PushCallbackDemo/Server/config.conf &
16 |
17 | sleep 1
18 |
19 | echo "client: ${EXE_PATH}/PushCallbackClient"
20 |
21 | ${EXE_PATH}/PushCallbackClient --config=${SRC_PATH}/examples/PushCallbackDemo/Client/config.conf
22 |
23 | sleep 1
24 |
25 | killall -9 PushCallbackServer
26 |
27 |
28 |
--------------------------------------------------------------------------------
/examples/scripts/run-push.bat:
--------------------------------------------------------------------------------
1 |
2 | echo "run-push.bat"
3 |
4 | set EXE_PATH=%1
5 | set SRC_PATH=%2\\..
6 |
7 | echo %EXE_PATH% %SRC_PATH%
8 |
9 | taskkill /im PushServer.exe /t /f
10 |
11 | timeout /T 1
12 |
13 | echo "start server: %EXE_PATH%\\PushServer.exe --config=%SRC_PATH%\\examples\\PushDemo\\PushServer\\config.conf"
14 |
15 | start /b %EXE_PATH%\\PushServer.exe --config=%SRC_PATH%\\examples\\PushDemo\\PushServer\\config.conf
16 |
17 | timeout /T 3
18 |
19 | ::-------------------------------------------------------------------------------------------------------
20 |
21 | echo "client: %EXE_PATH%\\PushClient.exe"
22 |
23 | %EXE_PATH%\\PushClient.exe 5
24 |
25 | taskkill /im PushServer.exe /t /f
26 |
27 |
--------------------------------------------------------------------------------
/examples/scripts/run-push.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo "run-co.sh"
4 | EXE_PATH=$1
5 | SRC_PATH=$2/..
6 |
7 | echo ${EXE_PATH} ${SRC_PATH}
8 |
9 | killall -9 PushServer
10 |
11 | sleep 1
12 | echo "start server: ${EXE_PATH}/PushServer --config=${SRC_PATH}/examples/PushDemo/PushServer/config.conf &"
13 |
14 | ${EXE_PATH}/PushServer --config=${SRC_PATH}/examples/PushDemo/PushServer/config.conf &
15 |
16 | sleep 2
17 |
18 | #-------------------------------------------------------------------------------------------------------
19 |
20 | echo "client: ${EXE_PATH}/PushClient"
21 |
22 | ${EXE_PATH}/PushClient 5
23 |
24 | killall -9 PushServer
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/examples/scripts/run-quick-start.bat:
--------------------------------------------------------------------------------
1 |
2 | echo "run-quick-start.bat"
3 |
4 | set EXE_PATH=%1
5 | set SRC_PATH=%2\\..
6 |
7 | echo %EXE_PATH% %SRC_PATH%
8 |
9 | taskkill /im QuickStartDemo.exe /t /f
10 | taskkill /im ProxyServer.exe /t /f
11 | timeout /T 1
12 |
13 | echo "start server: %EXE_PATH%\\QuickStartDemo.exe --config=%SRC_PATH%\\examples\\QuickStartDemo\\HelloServer\\Server\\config.conf "
14 |
15 | start /b %EXE_PATH%\\QuickStartDemo.exe --config=%SRC_PATH%\\examples\\QuickStartDemo\\HelloServer\\Server\\config.conf
16 | start /b %EXE_PATH%\\ProxyServer.exe --config=%SRC_PATH%\\examples\\QuickStartDemo\\ProxyServer\\Server\\config.conf
17 |
18 | timeout /T 3
19 |
20 | echo "client: %EXE_PATH%\\QuickStartDemoClient.exe"
21 |
22 | %EXE_PATH%\\QuickStartDemoClient.exe --count=100000 --call=sync --thread=2 --buffersize=100 --netthread=2
23 |
24 | %EXE_PATH%\\QuickStartDemoClient.exe --count=100000 --call=async --thread=2 --buffersize=100 --netthread=2
25 |
26 | %EXE_PATH%\\QuickStartDemoClient.exe --count=100000 --call=synctup --thread=2 --buffersize=100 --netthread=2
27 |
28 | %EXE_PATH%\\QuickStartDemoClient.exe --count=100000 --call=asynctup --thread=2 --buffersize=100 --netthread=2
29 |
30 | echo "client: %EXE_PATH%\\ProxyServerClient.exe"
31 |
32 | %EXE_PATH%\\ProxyServerClient.exe
33 |
34 | timeout /T 1
35 |
36 | taskkill /im QuickStartDemo.exe /t /f
37 | taskkill /im ProxyServer.exe /t /f
38 |
--------------------------------------------------------------------------------
/examples/scripts/run-quick-start.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo "run-quick-start.sh"
4 | EXE_PATH=$1
5 | SRC_PATH=$2/..
6 |
7 | echo ${EXE_PATH} ${SRC_PATH}
8 |
9 | killall -9 QuickStartDemo ProxyServer
10 |
11 | sleep 1
12 | echo "start server: ${EXE_PATH}/QuickStartDemo --config=${SRC_PATH}/examples/QuickStartDemo/HelloServer/Server/config.conf &"
13 |
14 | ${EXE_PATH}/QuickStartDemo --config=${SRC_PATH}/examples/QuickStartDemo/HelloServer/Server/config.conf &
15 | ${EXE_PATH}/ProxyServer --config=${SRC_PATH}/examples/QuickStartDemo/ProxyServer/Server/config.conf &
16 |
17 | sleep 2
18 |
19 | echo "client: ${EXE_PATH}/QuickStartDemoClient"
20 |
21 | ${EXE_PATH}/QuickStartDemoClient --count=100000 --call=sync --thread=2 --buffersize=100 --netthread=2
22 |
23 | ${EXE_PATH}/QuickStartDemoClient --count=100000 --call=async --thread=2 --buffersize=100 --netthread=2
24 |
25 | ${EXE_PATH}/QuickStartDemoClient --count=100000 --call=synctup --thread=2 --buffersize=100 --netthread=2
26 |
27 | ${EXE_PATH}/QuickStartDemoClient --count=100000 --call=asynctup --thread=2 --buffersize=100 --netthread=2
28 |
29 | echo "client: ${EXE_PATH}/ProxyServerClient"
30 |
31 | ${EXE_PATH}/ProxyServerClient
32 |
33 | sleep 1
34 |
35 | killall -9 ProxyServer QuickStartDemo
36 |
37 |
38 |
--------------------------------------------------------------------------------
/examples/scripts/run-ssl.bat:
--------------------------------------------------------------------------------
1 |
2 | echo "run-ssl.bat"
3 |
4 | set EXE_PATH=%1
5 | set SRC_PATH=%2\\..
6 |
7 | echo %EXE_PATH% %SRC_PATH%
8 |
9 | taskkill /im SSLServer.exe /t /f
10 | timeout /T 1
11 |
12 | echo "start server: %EXE_PATH%\\SSLServer.exe --config=%SRC_PATH%\\examples\\SSLDemo\\Server\\config.conf "
13 |
14 | start /b %EXE_PATH%\\SSLServer.exe --config=%SRC_PATH%\\examples\\SSLDemo\\Server\\config.conf
15 |
16 | sleep 3
17 |
18 | echo "client: %EXE_PATH%\\SSLClient.exe"
19 |
20 | %EXE_PATH%\\SSLClient.exe --count=10000 --thread=2 --call=sync --buffersize=1000 --netthread=1
21 | %EXE_PATH%\\SSLClient.exe --count=10000 --thread=2 --call=async --buffersize=1000 --netthread=1
22 |
23 | %EXE_PATH%\\SSLClient.exe --count=10000 --thread=2 --call=syncauth --buffersize=1000 --netthread=1
24 | %EXE_PATH%\\SSLClient.exe --count=10000 --thread=2 --call=asyncauth --buffersize=1000 --netthread=1
25 |
26 | timeout /T 1
27 |
28 | taskkill /im SSLServer.exe /t /f
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/examples/scripts/run-udp.bat:
--------------------------------------------------------------------------------
1 |
2 | echo "run-auth.bat"
3 |
4 | set EXE_PATH=%1
5 | set SRC_PATH=%2\\..
6 |
7 | echo %EXE_PATH% %SRC_PATH%
8 |
9 | taskkill /im UdpServer.exe /t /f
10 |
11 | timeout /T 1
12 |
13 | echo "start server: %EXE_PATH%/UdpServer.exe --config=%SRC_PATH%/examples/UdpDemo/Server/config.conf"
14 |
15 | start /b %EXE_PATH%\\UdpServer.exe --config=%SRC_PATH%\\examples\\UdpDemo\\Server\\config.conf
16 |
17 | timeout /T 3
18 |
19 | echo "client: ${EXE_PATH}/UdpClient.exe"
20 |
21 | %EXE_PATH%\\UdpClient.exe --count=10000 --thread=2 --call=sync --buffersize=1000 --netthread=1
22 | %EXE_PATH%\\UdpClient.exe --count=10000 --thread=2 --call=async --buffersize=1000 --netthread=1
23 |
24 | timeout /T 1
25 |
26 | taskkill /im UdpServer.exe /t /f
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/examples/scripts/run-udp.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo "run-auth.sh"
4 |
5 | EXE_PATH=$1
6 | SRC_PATH=$2/..
7 |
8 | echo ${EXE_PATH} ${SRC_PATH}
9 |
10 | killall -9 UdpServer
11 |
12 | sleep 1
13 | echo "start server: ${EXE_PATH}/UdpServer --config=${SRC_PATH}/examples/UdpDemo/Server/config.conf &"
14 |
15 | ${EXE_PATH}/UdpServer --config=${SRC_PATH}/examples/UdpDemo/Server/config.conf &
16 |
17 | sleep 1
18 |
19 | echo "client: ${EXE_PATH}/UdpClient"
20 |
21 | ${EXE_PATH}/UdpClient --config=${SRC_PATH}/examples/UdpDemo/Client/config.conf --count=10000 --thread=2 --call=sync --buffersize=1000 --netthread=1
22 | ${EXE_PATH}/UdpClient --config=${SRC_PATH}/examples/UdpDemo/Client/config.conf --count=10000 --thread=2 --call=async --buffersize=1000 --netthread=1
23 |
24 | sleep 1
25 |
26 | killall -9 UdpServer
27 |
28 |
29 |
--------------------------------------------------------------------------------
/mock/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | include_directories(../)
3 | file(GLOB_RECURSE SRC_FILES *.cpp)
4 | add_library(tarsmock STATIC ${SRC_FILES})
5 |
6 | add_dependencies(tarsmock tarsservant)
7 |
8 | install(DIRECTORY . DESTINATION include/mock FILES_MATCHING PATTERN "*.h")
9 |
10 | install(TARGETS tarsmock RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
11 |
12 | # if(ENABLE_SHARED)
13 | # add_library(tarsmock_shared SHARED ${SRC_FILES})
14 | # target_compile_definitions(tarsmock_shared PRIVATE SVT_USE_DLL UTIL_USE_DLL)
15 | # target_link_libraries(tarsmock_shared tarsservant_shared tarsutil_shared)
16 | # add_dependencies(tarsmock_shared tarsservant_shared)
17 |
18 | # install(TARGETS tarsmock_shared RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
19 |
20 | # if (WIN32)
21 | # install(FILES $ DESTINATION bin)
22 | # endif()
23 |
24 | # endif()
25 |
--------------------------------------------------------------------------------
/mock/ConfigImp.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "ConfigImp.h"
3 |
4 | map ConfigImp::files;
5 | std::mutex ConfigImp::_mutex;
6 |
7 | void ConfigImp::setConfigFile(const string &name, const string &content)
8 | {
9 | std::lock_guard lock(_mutex);
10 | files[name] = content;
11 | }
12 |
--------------------------------------------------------------------------------
/mock/FrameworkServer.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include "servant/Application.h"
5 |
6 | using namespace tars;
7 |
8 | extern vector