├── BUILD ├── cmake ├── README.md └── tools │ └── copy_fmt_to_spdlog.sh ├── docs ├── zh │ ├── README.md │ └── faq.md ├── images │ ├── filter.png │ ├── tracing.png │ ├── arch_design.png │ ├── filter_point.png │ ├── log_design.png │ ├── backup_request.png │ ├── config_design.png │ ├── dir_structure.png │ ├── fiber_limiter.png │ ├── plugin_factory.png │ ├── rpcz_design_en.png │ ├── rpcz_design_zh.png │ ├── rpcz_perfetto.png │ ├── rpcz_sample_en.png │ ├── rpcz_sample_zh.png │ ├── admin_main_page.png │ ├── m_n_coroutine_en.png │ ├── m_n_coroutine_zh.png │ ├── timeout_control.png │ ├── concurrency_limiter.png │ ├── interaction_process.png │ ├── fiber_threadmodel_arch.png │ ├── flow_control_limiter.png │ ├── merge_threadmodel_arch.png │ ├── quick_start_helloworld.png │ ├── transparent_service_en.png │ ├── transparent_service_zh.png │ ├── future_promise_state_en.png │ ├── future_promise_state_zh.png │ ├── faq │ │ ├── crash_when_double_free.png │ │ ├── client_invoke_error_code.png │ │ ├── crash_when_port_conflict.png │ │ ├── http_problem_wrong_usage.png │ │ ├── crash_when_throw_exectpion.png │ │ └── crash_when_then_capture_raw_pointer.png │ ├── flow_control_limiter_smooth.png │ ├── future_promise_structure_en.png │ ├── future_promise_structure_zh.png │ ├── rpcz_client_filter_point_en.png │ ├── rpcz_client_filter_point_zh.png │ ├── rpcz_server_filter_point_en.png │ ├── rpcz_server_filter_point_zh.png │ ├── separate_threadmodel_arch.png │ ├── trpc_protocol_client-async.png │ ├── trpc_protocol_client-client.png │ ├── flow_control_limiter_second_1.png │ ├── flow_control_limiter_second_2.png │ ├── trpc_protocol_client-forword.png │ ├── trpc_protocol_service_stub_en.png │ ├── trpc_protocol_service_stub_zh.png │ ├── client_guide_invoke_routine_en.png │ ├── client_guide_invoke_routine_zh.png │ └── trpc_protocol_client-rpc_interface.png └── high_percenttile_limiter.png ├── test ├── README.md └── end2end │ ├── BUILD │ ├── stream │ ├── BUILD │ └── trpc │ │ ├── conf │ │ ├── BUILD │ │ ├── sync_test │ │ │ ├── async_stream_server.yaml │ │ │ └── sync_stream_server.yaml │ │ └── async_test │ │ │ ├── async_stream_server.yaml │ │ │ └── sync_stream_server.yaml │ │ ├── async_stream_server.h │ │ └── sync_stream_server.h │ ├── unary │ ├── BUILD │ ├── rpcz │ │ ├── conf │ │ │ ├── BUILD │ │ │ ├── rpcz_real_server_merge.yaml │ │ │ ├── rpcz_real_server_fiber.yaml │ │ │ ├── rpcz_real_server_separate.yaml │ │ │ ├── rpcz_client_merge.yaml │ │ │ ├── rpcz_client_fiber.yaml │ │ │ └── rpcz_client_separate.yaml │ │ └── README.md │ ├── future │ │ ├── conf │ │ │ ├── BUILD │ │ │ ├── future_server_merge.yaml │ │ │ └── future_server_separate.yaml │ │ ├── future.proto │ │ └── README.md │ ├── redis │ │ └── conf │ │ │ ├── BUILD │ │ │ ├── redis_server.yaml │ │ │ ├── redis_client_merge.yaml │ │ │ ├── redis_client_fiber.yaml │ │ │ └── redis_client_separate.yaml │ ├── trpc │ │ ├── conf │ │ │ └── BUILD │ │ ├── trpc_test.fbs │ │ ├── common_funcs.h │ │ ├── trpc_server.h │ │ └── trpc_route_server.h │ ├── tvar │ │ └── conf │ │ │ ├── BUILD │ │ │ ├── tvar_client_merge.yaml │ │ │ ├── tvar_server_fiber.yaml │ │ │ ├── tvar_server_merge.yaml │ │ │ ├── tvar_client_merge_noseries.yaml │ │ │ ├── tvar_server_fiber_noseries.yaml │ │ │ ├── tvar_server_merge_noseries.yaml │ │ │ ├── tvar_server_separate.yaml │ │ │ ├── tvar_server_separate_noseries.yaml │ │ │ ├── tvar_client_fiber.yaml │ │ │ ├── tvar_client_fiber_noseries.yaml │ │ │ ├── tvar_client_separate.yaml │ │ │ └── tvar_client_separate_noseries.yaml │ ├── fiber │ │ ├── conf │ │ │ └── fiber_test │ │ │ │ ├── BUILD │ │ │ │ ├── fiber_client.yaml │ │ │ │ └── fiber_server.yaml │ │ └── README.md │ └── http │ │ ├── conf │ │ ├── http_rpc_test │ │ │ ├── BUILD │ │ │ ├── http_server_merge.yaml │ │ │ ├── http_server_separate.yaml │ │ │ ├── http_client_merge.yaml │ │ │ └── http_client_separate.yaml │ │ ├── http_test │ │ │ ├── BUILD │ │ │ ├── http_client_fiber.yaml │ │ │ ├── http_server_fiber.yaml │ │ │ ├── http_server_merge.yaml │ │ │ ├── http_client_merge.yaml │ │ │ ├── http_server_separate.yaml │ │ │ └── http_client_separate.yaml │ │ └── https_test │ │ │ ├── BUILD │ │ │ └── dhparam.pem │ │ └── http_rpc.proto │ ├── README.md │ └── gracefully_stop │ ├── run_test.sh │ └── README.md ├── trpc ├── log │ ├── README.md │ ├── trpc_log.h │ ├── printf_like.h │ ├── python_like.h │ └── stream_like.h ├── client │ ├── README.md │ ├── grpc │ │ ├── testing │ │ │ └── BUILD │ │ └── BUILD │ └── trpc_service_proxy.h ├── codec │ ├── README.md │ ├── trpc │ │ ├── README.md │ │ ├── trpc.proto │ │ └── testing │ │ │ └── BUILD │ ├── http │ │ └── README.md │ ├── grpc │ │ └── http2 │ │ │ └── testing │ │ │ └── BUILD │ └── non_rpc_protocol.h ├── config │ ├── README.md │ ├── provider │ │ └── local_file │ │ │ └── README.md │ ├── codec │ │ └── common │ │ │ └── BUILD │ └── testing │ │ ├── test.yaml │ │ ├── test_load.toml │ │ ├── test_load.yaml │ │ └── test_load.json ├── metrics │ ├── README.md │ ├── testing │ │ ├── metrics.yaml │ │ └── BUILD │ └── prometheus │ │ └── testing │ │ └── prometheus_metrics.yaml ├── server │ ├── README.md │ ├── rpc_method_handler.h │ ├── rpc_service_method.h │ ├── non_rpc_service_impl.h │ ├── non_rpc_method_handler.h │ ├── non_rpc_service_method.h │ ├── stream_rpc_method_handler.h │ ├── rpc_async_method_handler.h │ ├── stream_rpc_async_method_handler.h │ └── rpc_service_impl.h ├── stream │ ├── README.md │ ├── trpc │ │ └── testing │ │ │ └── BUILD │ ├── http │ │ ├── async │ │ │ ├── testing │ │ │ │ └── BUILD │ │ │ └── server │ │ │ │ └── testing │ │ │ │ └── BUILD │ │ └── common │ │ │ ├── testing │ │ │ └── BUILD │ │ │ ├── client │ │ │ └── BUILD │ │ │ └── server │ │ │ └── BUILD │ ├── testing │ │ └── stream.proto │ └── stream_handler_manager.h ├── tools │ ├── README.md │ ├── comm │ │ ├── trpc_cpp_options.proto │ │ └── BUILD │ └── flatbuffers_tool │ │ └── testing │ │ └── greeter.fbs ├── tracing │ └── README.md ├── util │ ├── README.md │ ├── log │ │ ├── README.md │ │ ├── default │ │ │ ├── testing │ │ │ │ └── BUILD │ │ │ └── sinks │ │ │ │ └── stdout │ │ │ │ └── BUILD │ │ └── testing │ │ │ └── BUILD │ ├── internal │ │ └── README.md │ ├── object_pool │ │ └── README.md │ ├── testing │ │ ├── testjson.proto │ │ └── BUILD │ ├── queue │ │ └── detail │ │ │ └── BUILD │ ├── async_io │ │ ├── BUILD │ │ └── async_io.h │ ├── buffer │ │ └── testing │ │ │ └── BUILD │ ├── hash_util.h │ ├── http │ │ ├── reply.h │ │ ├── body_params.h │ │ └── http_header.h │ ├── lockfree_queue.h │ ├── doubly_linked_list.h │ ├── thread │ │ ├── bounded_mpmc_queue.h │ │ ├── bounded_mpsc_queue.h │ │ ├── unbounded_spmc_queue.h │ │ ├── internal │ │ │ └── BUILD │ │ ├── memory_barrier.h │ │ └── thread_pool_option.h │ ├── algorithm │ │ ├── BUILD │ │ └── power_of_two.h │ ├── latch.h │ ├── random.h │ ├── string_util.h │ ├── string_helper.h │ ├── hazptr │ │ ├── BUILD │ │ └── hazptr_object.cc │ └── likely.h ├── coroutine │ ├── README.md │ ├── fiber │ │ ├── BUILD │ │ └── runtime.h │ └── fiber_mutex.h ├── naming │ ├── direct │ │ └── README.md │ ├── domain │ │ └── README.md │ ├── testing │ │ └── domain_test.yaml │ └── common │ │ ├── util │ │ ├── BUILD │ │ └── loadbalance │ │ │ └── polling │ │ │ └── BUILD │ │ └── constants.h ├── transport │ ├── README.md │ ├── common │ │ ├── ssl │ │ │ └── cert │ │ │ │ ├── ca │ │ │ │ └── xxops-com-chain │ │ │ │ │ ├── root-ca.srl │ │ │ │ │ ├── mk_xxops_com_dhparam.sh │ │ │ │ │ ├── mk_ca_root_key.sh │ │ │ │ │ ├── xxops-com.dhparam │ │ │ │ │ └── mk_xxops_com_csr_cert.sh │ │ │ │ ├── README.md │ │ │ │ ├── server_dhparam.pem │ │ │ │ └── xxops-com.dhparam │ │ ├── transport_message.h │ │ ├── io_handler_manager.h │ │ ├── connection_handler_manager.h │ │ └── io_handler_manager_test.cc │ ├── client │ │ ├── future │ │ │ ├── testing │ │ │ │ └── merge_separate_threadmodel.yaml │ │ │ └── README.md │ │ └── preallocation_option.h │ └── server │ │ └── testing │ │ └── BUILD ├── runtime │ ├── iomodel │ │ ├── README.md │ │ ├── BUILD │ │ └── reactor │ │ │ ├── testing │ │ │ └── BUILD │ │ │ └── BUILD │ ├── threadmodel │ │ ├── fiber │ │ │ └── README.md │ │ ├── testing │ │ │ ├── merge.yaml │ │ │ ├── fiber.yaml │ │ │ ├── separate.yaml │ │ │ └── BUILD │ │ └── BUILD │ ├── testing │ │ └── BUILD │ ├── common │ │ ├── runtime_info_report │ │ │ └── test.yaml │ │ └── stats │ │ │ └── server_stats.yaml │ └── init_runtime.h ├── auth │ ├── README.md │ └── testing │ │ └── BUILD ├── common │ ├── future │ │ ├── README.md │ │ ├── types.h │ │ ├── basics.h │ │ ├── executor.h │ │ ├── future.h │ │ ├── exception.h │ │ ├── function_traits.h │ │ ├── future_utility.h │ │ └── reactor_executor.h │ ├── testing │ │ ├── merge_testing.yaml │ │ ├── BUILD │ │ └── fiber_testing.yaml │ ├── logging │ │ ├── BUILD │ │ └── trpc_logging.h │ ├── coroutine │ │ ├── BUILD │ │ ├── trpc │ │ │ └── trpc_task_executer.h │ │ └── task_executer.h │ ├── async_timer.h │ └── trpc_version.cc ├── compressor │ ├── README.md │ ├── testing │ │ └── BUILD │ ├── gzip │ │ └── BUILD │ ├── zlib │ │ └── BUILD │ └── snappy │ │ └── BUILD ├── serialization │ ├── README.md │ ├── testing │ │ ├── test_serialization.proto │ │ └── BUILD │ ├── noop │ │ └── BUILD │ └── trpc_serialization.h ├── rpcz │ └── testing │ │ └── BUILD ├── tvar │ ├── testing │ │ ├── BUILD │ │ ├── series.yaml │ │ └── noseries.yaml │ ├── README.md │ └── BUILD ├── proto │ ├── testing │ │ ├── helloworld.fbs │ │ └── helloworld.proto │ ├── BUILD │ └── trpc_options.proto ├── overload_control │ ├── common │ │ └── report_test.yaml │ └── BUILD ├── admin │ ├── perl_tools │ │ ├── BUILD │ │ └── pprof.h │ └── js │ │ ├── flot_min_js.h │ │ ├── jquery_min_js.h │ │ ├── viz_min_js.h │ │ └── viz_min_js_test.cc └── filter │ ├── filter.h │ ├── testing │ └── BUILD │ └── trpc_filter.h ├── docker ├── dockerfile-gcc7 └── dockerfile-gcc8 ├── third_party ├── README.md ├── zlib │ └── BUILD ├── com_github_lz4_lz4 │ └── BUILD ├── com_github_axboe_liburing │ └── BUILD ├── com_github_fmtlib_fmt │ └── BUILD ├── com_github_gabime_spdlog │ ├── BUILD │ └── spdlog.BUILD ├── com_github_google_snappy │ └── BUILD ├── com_github_madler_zlib │ └── BUILD ├── com_github_google_flatbuffers │ └── BUILD ├── com_github_h2o_picohttpparser │ ├── BUILD │ └── picohttpparser.BUILD ├── com_github_nghttp2_nghttp2 │ ├── BUILD │ └── nghttp2.BUILD ├── com_github_tencent_rapidjson │ ├── BUILD │ └── rapidjson.BUILD ├── com_github_toruniina_toml11 │ ├── BUILD │ └── toml.BUILD └── BUILD ├── CHANGELOG.md ├── examples ├── features │ ├── filter │ │ ├── BUILD │ │ ├── run.sh │ │ ├── run_cmake.sh │ │ ├── common │ │ │ └── BUILD │ │ ├── client │ │ │ ├── trpc_cpp_separate.yaml │ │ │ └── BUILD │ │ └── server │ │ │ └── BUILD │ ├── request_dispatch │ │ ├── client │ │ │ ├── trpc_cpp_future.yaml │ │ │ └── trpc_cpp_fiber.yaml │ │ └── server │ │ │ ├── BUILD │ │ │ └── trpc_cpp_separate.yaml │ ├── trpc_flatbuffers │ │ ├── proxy │ │ │ ├── forward.fbs │ │ │ └── greeter.fbs │ │ ├── client │ │ │ ├── trpc_cpp_fiber.yaml │ │ │ └── BUILD │ │ ├── server │ │ │ └── greeter.fbs │ │ ├── run.sh │ │ └── run_cmake.sh │ ├── https │ │ ├── cert │ │ │ ├── README.md │ │ │ └── server_dhparam.pem │ │ └── server │ │ │ └── BUILD │ ├── future_forward │ │ ├── client │ │ │ ├── trpc_cpp_future.yaml │ │ │ └── BUILD │ │ └── proxy │ │ │ └── forward.proto │ ├── http │ │ ├── client │ │ │ ├── trpc_cpp_fiber.yaml │ │ │ └── BUILD │ │ └── server │ │ │ ├── BUILD │ │ │ └── trpc_cpp_fiber.yaml │ ├── http_rpc │ │ ├── client │ │ │ ├── trpc_cpp_fiber.yaml │ │ │ └── BUILD │ │ └── server │ │ │ ├── BUILD │ │ │ └── trpc_cpp_fiber.yaml │ ├── fiber_forward │ │ ├── client │ │ │ ├── trpc_cpp_fiber.yaml │ │ │ └── BUILD │ │ └── proxy │ │ │ └── forward.proto │ ├── trpc_json │ │ ├── client │ │ │ ├── trpc_cpp_fiber.yaml │ │ │ └── BUILD │ │ ├── run.sh │ │ ├── server │ │ │ └── BUILD │ │ └── run_cmake.sh │ ├── trpc_noop │ │ ├── client │ │ │ ├── trpc_cpp_fiber.yaml │ │ │ └── BUILD │ │ ├── run.sh │ │ ├── server │ │ │ └── BUILD │ │ └── run_cmake.sh │ ├── trpc_stream │ │ ├── client │ │ │ └── trpc_cpp_fiber.yaml │ │ └── server │ │ │ └── stream.proto │ ├── trpc_attachment │ │ ├── client │ │ │ ├── trpc_cpp_fiber.yaml │ │ │ └── BUILD │ │ ├── server │ │ │ └── BUILD │ │ ├── run.sh │ │ └── run_cmake.sh │ ├── trpc_compressor │ │ ├── client │ │ │ ├── trpc_cpp_fiber.yaml │ │ │ └── BUILD │ │ ├── run.sh │ │ └── run_cmake.sh │ ├── trpc_transparent │ │ └── client │ │ │ ├── trpc_cpp_fiber.yaml │ │ │ └── BUILD │ ├── http_upload_download │ │ ├── client │ │ │ └── trpc_cpp_fiber.yaml │ │ └── server │ │ │ └── trpc_cpp_fiber.yaml │ ├── thirdparty_protocol │ │ ├── client │ │ │ ├── trpc_cpp_fiber.yaml │ │ │ └── BUILD │ │ ├── run.sh │ │ ├── run_cmake.sh │ │ └── server │ │ │ └── BUILD │ ├── trpc_stream_forward │ │ ├── client │ │ │ ├── trpc_cpp_fiber.yaml │ │ │ └── BUILD │ │ └── proxy │ │ │ └── stream_forward.proto │ ├── admin │ │ ├── proxy │ │ │ └── forward.proto │ │ └── client │ │ │ ├── trpc_cpp.yaml │ │ │ └── BUILD │ ├── grpc_stream │ │ ├── common │ │ │ └── BUILD │ │ └── server │ │ │ └── trpc_cpp_fiber.yaml │ ├── prometheus │ │ ├── proxy │ │ │ └── forward.proto │ │ └── client │ │ │ ├── trpc_cpp_fiber.yaml │ │ │ └── BUILD │ ├── tvar │ │ ├── client │ │ │ ├── trpc_cpp_client.yaml │ │ │ └── BUILD │ │ └── server │ │ │ └── tvar_server.h │ ├── rpcz │ │ ├── proxy │ │ │ ├── rpcz.proto │ │ │ └── rpcz_proxy.h │ │ └── client │ │ │ ├── trpc_cpp_client.yaml │ │ │ └── BUILD │ ├── http_async_upload_download │ │ └── server │ │ │ └── BUILD │ ├── redis │ │ └── client │ │ │ ├── future │ │ │ └── BUILD │ │ │ └── fiber │ │ │ └── BUILD │ └── trpc_async_stream │ │ └── server │ │ └── BUILD ├── helloworld │ ├── helloworld.proto │ └── run.sh └── unittest │ ├── BUILD │ ├── helloworld.proto │ ├── client │ └── trpc_cpp.yaml │ └── server │ └── async │ └── trpc_cpp.yaml ├── clean.sh ├── WORKSPACE ├── .bazelrc ├── .github └── .codecov.yml ├── .clang-format └── .gitignore /BUILD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cmake/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/zh/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/end2end/BUILD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /trpc/log/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docker/dockerfile-gcc7: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docker/dockerfile-gcc8: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/zlib/BUILD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /trpc/client/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /trpc/codec/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /trpc/config/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /trpc/metrics/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /trpc/server/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /trpc/stream/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /trpc/tools/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /trpc/tracing/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /trpc/util/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /trpc/util/log/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log -------------------------------------------------------------------------------- /test/end2end/stream/BUILD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/end2end/unary/BUILD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /trpc/codec/trpc/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /trpc/coroutine/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /trpc/naming/direct/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /trpc/naming/domain/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /trpc/transport/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /trpc/util/internal/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/features/filter/BUILD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /trpc/runtime/iomodel/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /trpc/util/object_pool/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/com_github_lz4_lz4/BUILD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/end2end/README.md: -------------------------------------------------------------------------------- 1 | # end2end testing -------------------------------------------------------------------------------- /third_party/com_github_axboe_liburing/BUILD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/com_github_fmtlib_fmt/BUILD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/com_github_gabime_spdlog/BUILD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/com_github_google_snappy/BUILD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/com_github_madler_zlib/BUILD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /trpc/auth/README.md: -------------------------------------------------------------------------------- 1 | Token-based auth plugin. -------------------------------------------------------------------------------- /trpc/config/provider/local_file/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /trpc/runtime/threadmodel/fiber/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/com_github_google_flatbuffers/BUILD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/com_github_h2o_picohttpparser/BUILD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/com_github_nghttp2_nghttp2/BUILD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/com_github_tencent_rapidjson/BUILD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/com_github_toruniina_toml11/BUILD: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /trpc/codec/http/README.md: -------------------------------------------------------------------------------- 1 | HTTP protocol checker. -------------------------------------------------------------------------------- /clean.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | bazel clean --expunge 4 | -------------------------------------------------------------------------------- /trpc/transport/common/ssl/cert/ca/xxops-com-chain/root-ca.srl: -------------------------------------------------------------------------------- 1 | A65262790647EC1B 2 | -------------------------------------------------------------------------------- /trpc/codec/trpc/trpc.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | import "trpc/proto/trpc.proto"; 4 | -------------------------------------------------------------------------------- /trpc/common/future/README.md: -------------------------------------------------------------------------------- 1 | This module is deprecated, use trpc/future module instead. 2 | -------------------------------------------------------------------------------- /docs/images/filter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/filter.png -------------------------------------------------------------------------------- /docs/images/tracing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/tracing.png -------------------------------------------------------------------------------- /docs/images/arch_design.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/arch_design.png -------------------------------------------------------------------------------- /docs/images/filter_point.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/filter_point.png -------------------------------------------------------------------------------- /docs/images/log_design.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/log_design.png -------------------------------------------------------------------------------- /third_party/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | -------------------------------------------------------------------------------- /docs/images/backup_request.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/backup_request.png -------------------------------------------------------------------------------- /docs/images/config_design.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/config_design.png -------------------------------------------------------------------------------- /docs/images/dir_structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/dir_structure.png -------------------------------------------------------------------------------- /docs/images/fiber_limiter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/fiber_limiter.png -------------------------------------------------------------------------------- /docs/images/plugin_factory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/plugin_factory.png -------------------------------------------------------------------------------- /docs/images/rpcz_design_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/rpcz_design_en.png -------------------------------------------------------------------------------- /docs/images/rpcz_design_zh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/rpcz_design_zh.png -------------------------------------------------------------------------------- /docs/images/rpcz_perfetto.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/rpcz_perfetto.png -------------------------------------------------------------------------------- /docs/images/rpcz_sample_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/rpcz_sample_en.png -------------------------------------------------------------------------------- /docs/images/rpcz_sample_zh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/rpcz_sample_zh.png -------------------------------------------------------------------------------- /trpc/compressor/README.md: -------------------------------------------------------------------------------- 1 | Compressor Plugin 2 | 3 | Support: 4 | - gzip 5 | - lz4 6 | - snappy 7 | - zlib 8 | -------------------------------------------------------------------------------- /trpc/naming/testing/domain_test.yaml: -------------------------------------------------------------------------------- 1 | plugins: 2 | selector: 3 | domain: 4 | exclude_ipv6: true 5 | -------------------------------------------------------------------------------- /docs/high_percenttile_limiter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/high_percenttile_limiter.png -------------------------------------------------------------------------------- /docs/images/admin_main_page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/admin_main_page.png -------------------------------------------------------------------------------- /docs/images/m_n_coroutine_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/m_n_coroutine_en.png -------------------------------------------------------------------------------- /docs/images/m_n_coroutine_zh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/m_n_coroutine_zh.png -------------------------------------------------------------------------------- /docs/images/timeout_control.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/timeout_control.png -------------------------------------------------------------------------------- /trpc/runtime/iomodel/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | -------------------------------------------------------------------------------- /docs/images/concurrency_limiter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/concurrency_limiter.png -------------------------------------------------------------------------------- /docs/images/interaction_process.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/interaction_process.png -------------------------------------------------------------------------------- /trpc/serialization/README.md: -------------------------------------------------------------------------------- 1 | Serialization Plugin 2 | 3 | Support: 4 | - pb 5 | - json 6 | - flatbuffers 7 | - binary/text -------------------------------------------------------------------------------- /WORKSPACE: -------------------------------------------------------------------------------- 1 | workspace(name = "trpc_cpp") 2 | 3 | load("//trpc:workspace.bzl", "trpc_workspace") 4 | 5 | trpc_workspace() 6 | -------------------------------------------------------------------------------- /docs/images/fiber_threadmodel_arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/fiber_threadmodel_arch.png -------------------------------------------------------------------------------- /docs/images/flow_control_limiter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/flow_control_limiter.png -------------------------------------------------------------------------------- /docs/images/merge_threadmodel_arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/merge_threadmodel_arch.png -------------------------------------------------------------------------------- /docs/images/quick_start_helloworld.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/quick_start_helloworld.png -------------------------------------------------------------------------------- /docs/images/transparent_service_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/transparent_service_en.png -------------------------------------------------------------------------------- /docs/images/transparent_service_zh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/transparent_service_zh.png -------------------------------------------------------------------------------- /docs/images/future_promise_state_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/future_promise_state_en.png -------------------------------------------------------------------------------- /docs/images/future_promise_state_zh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/future_promise_state_zh.png -------------------------------------------------------------------------------- /docs/images/faq/crash_when_double_free.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/faq/crash_when_double_free.png -------------------------------------------------------------------------------- /docs/images/flow_control_limiter_smooth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/flow_control_limiter_smooth.png -------------------------------------------------------------------------------- /docs/images/future_promise_structure_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/future_promise_structure_en.png -------------------------------------------------------------------------------- /docs/images/future_promise_structure_zh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/future_promise_structure_zh.png -------------------------------------------------------------------------------- /docs/images/rpcz_client_filter_point_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/rpcz_client_filter_point_en.png -------------------------------------------------------------------------------- /docs/images/rpcz_client_filter_point_zh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/rpcz_client_filter_point_zh.png -------------------------------------------------------------------------------- /docs/images/rpcz_server_filter_point_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/rpcz_server_filter_point_en.png -------------------------------------------------------------------------------- /docs/images/rpcz_server_filter_point_zh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/rpcz_server_filter_point_zh.png -------------------------------------------------------------------------------- /docs/images/separate_threadmodel_arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/separate_threadmodel_arch.png -------------------------------------------------------------------------------- /docs/images/trpc_protocol_client-async.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/trpc_protocol_client-async.png -------------------------------------------------------------------------------- /docs/images/trpc_protocol_client-client.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/trpc_protocol_client-client.png -------------------------------------------------------------------------------- /docs/images/faq/client_invoke_error_code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/faq/client_invoke_error_code.png -------------------------------------------------------------------------------- /docs/images/faq/crash_when_port_conflict.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/faq/crash_when_port_conflict.png -------------------------------------------------------------------------------- /docs/images/faq/http_problem_wrong_usage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/faq/http_problem_wrong_usage.png -------------------------------------------------------------------------------- /docs/images/flow_control_limiter_second_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/flow_control_limiter_second_1.png -------------------------------------------------------------------------------- /docs/images/flow_control_limiter_second_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/flow_control_limiter_second_2.png -------------------------------------------------------------------------------- /docs/images/trpc_protocol_client-forword.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/trpc_protocol_client-forword.png -------------------------------------------------------------------------------- /docs/images/trpc_protocol_service_stub_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/trpc_protocol_service_stub_en.png -------------------------------------------------------------------------------- /docs/images/trpc_protocol_service_stub_zh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/trpc_protocol_service_stub_zh.png -------------------------------------------------------------------------------- /trpc/util/testing/testjson.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package trpc.test; 4 | 5 | message TestMessage { 6 | string msg = 1; 7 | } 8 | -------------------------------------------------------------------------------- /docs/images/client_guide_invoke_routine_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/client_guide_invoke_routine_en.png -------------------------------------------------------------------------------- /docs/images/client_guide_invoke_routine_zh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/client_guide_invoke_routine_zh.png -------------------------------------------------------------------------------- /docs/images/faq/crash_when_throw_exectpion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/faq/crash_when_throw_exectpion.png -------------------------------------------------------------------------------- /docs/images/trpc_protocol_client-rpc_interface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/trpc_protocol_client-rpc_interface.png -------------------------------------------------------------------------------- /trpc/rpcz/testing/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | exports_files(["rpcz.yaml"]) 6 | -------------------------------------------------------------------------------- /docs/images/faq/crash_when_then_capture_raw_pointer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/trpc-cpp/main/docs/images/faq/crash_when_then_capture_raw_pointer.png -------------------------------------------------------------------------------- /trpc/runtime/testing/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | exports_files(["heartbeat_report_test.yaml"]) -------------------------------------------------------------------------------- /.bazelrc: -------------------------------------------------------------------------------- 1 | build --cxxopt="--std=c++17" 2 | build --copt=-O2 3 | #build --copt=-g --strip=never 4 | build --jobs 16 5 | #test --cache_test_results=no --test_output=errors 6 | -------------------------------------------------------------------------------- /trpc/common/testing/merge_testing.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | default: 4 | - instance_name: default_instance 5 | io_handle_type: merge 6 | io_thread_num: 4 -------------------------------------------------------------------------------- /trpc/tvar/testing/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | exports_files(["noseries.yaml"]) 6 | 7 | exports_files(["series.yaml"]) 8 | -------------------------------------------------------------------------------- /trpc/runtime/threadmodel/testing/merge.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | default: 4 | - instance_name: default_instance 5 | io_handle_type: merge 6 | io_thread_num: 8 7 | -------------------------------------------------------------------------------- /trpc/transport/common/ssl/cert/ca/xxops-com-chain/mk_xxops_com_dhparam.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | DHPARAM_NAME='xxopsop-com.dhparam' 4 | 5 | openssl dhparam 2048 -check -out ${DHPARAM_NAME} -------------------------------------------------------------------------------- /third_party/com_github_toruniina_toml11/toml.BUILD: -------------------------------------------------------------------------------- 1 | package( 2 | default_visibility = ["//visibility:public"], 3 | ) 4 | 5 | cc_library( 6 | name = "toml", 7 | hdrs = glob(["**/*.hpp"]), 8 | ) -------------------------------------------------------------------------------- /trpc/common/testing/BUILD: -------------------------------------------------------------------------------- 1 | 2 | licenses(["notice"]) 3 | 4 | package(default_visibility = ["//visibility:public"]) 5 | 6 | exports_files(["fiber_testing.yaml"]) 7 | 8 | exports_files(["merge_testing.yaml"]) 9 | -------------------------------------------------------------------------------- /trpc/log/trpc_log.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "trpc/util/log/logging.h" 4 | #include "trpc/util/log/printf_like.h" 5 | #include "trpc/util/log/python_like.h" 6 | #include "trpc/util/log/stream_like.h" 7 | -------------------------------------------------------------------------------- /trpc/util/queue/detail/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package( 4 | default_visibility = ["//visibility:public"], 5 | ) 6 | 7 | cc_library( 8 | name = "util", 9 | hdrs = ["util.h"], 10 | ) 11 | -------------------------------------------------------------------------------- /examples/features/request_dispatch/client/trpc_cpp_future.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | default: 4 | - instance_name: default_instance 5 | io_handle_type: merge 6 | io_thread_num: 4 7 | 8 | 9 | -------------------------------------------------------------------------------- /examples/features/trpc_flatbuffers/proxy/forward.fbs: -------------------------------------------------------------------------------- 1 | include "greeter.fbs"; 2 | 3 | namespace trpc.test.forward; 4 | 5 | rpc_service FbForward { 6 | Forward(trpc.test.helloworld.FbRequest):trpc.test.helloworld.FbReply; 7 | } 8 | -------------------------------------------------------------------------------- /examples/features/https/cert/README.md: -------------------------------------------------------------------------------- 1 | `cert` directory was used for unit testing only, it contains `Self-Sigined CA Key` and `Server Key`, 2 | they were used by unit test case. 3 | 4 | !!! Note: Don't used them in production environment. -------------------------------------------------------------------------------- /trpc/common/testing/fiber_testing.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | fiber: 4 | - instance_name: fiber_instance 5 | concurrency_hint: 8 6 | scheduling_group_size: 8 7 | reactor_num_per_scheduling_group: 1 -------------------------------------------------------------------------------- /trpc/transport/common/ssl/cert/README.md: -------------------------------------------------------------------------------- 1 | `cert` directory was used for unit testing only, it contains `Self-Sigined CA Key` and `Server Key`, 2 | they were used by unit test case. 3 | 4 | !!! Note: Don't used them in production environment. -------------------------------------------------------------------------------- /examples/features/future_forward/client/trpc_cpp_future.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | default: 4 | - instance_name: default_instance 5 | io_handle_type: separate 6 | io_thread_num: 1 7 | handle_thread_num: 1 -------------------------------------------------------------------------------- /trpc/metrics/testing/metrics.yaml: -------------------------------------------------------------------------------- 1 | plugins: 2 | metrics: 3 | prometheus: 4 | histogram_module_cfg: 5 | - 1 6 | - 2 7 | - 3 8 | const_labels: 9 | key1: value1 10 | key2: value2 11 | -------------------------------------------------------------------------------- /trpc/runtime/threadmodel/testing/fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | fiber: 4 | - instance_name: fiber_instance 5 | concurrency_hint: 8 6 | scheduling_group_size: 8 7 | reactor_num_per_scheduling_group: 2 8 | -------------------------------------------------------------------------------- /trpc/serialization/testing/test_serialization.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package trpc.test.serialization; 4 | 5 | message HelloRequest { 6 | string msg = 1; 7 | } 8 | 9 | message HelloReply { 10 | string msg = 1; 11 | } 12 | -------------------------------------------------------------------------------- /examples/features/http/client/trpc_cpp_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | fiber: 4 | - instance_name: fiber_instance 5 | concurrency_hint: 4 6 | scheduling_group_size: 4 7 | reactor_num_per_scheduling_group: 1 -------------------------------------------------------------------------------- /examples/features/http_rpc/client/trpc_cpp_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | fiber: 4 | - instance_name: fiber_instance 5 | concurrency_hint: 4 6 | scheduling_group_size: 4 7 | reactor_num_per_scheduling_group: 1 -------------------------------------------------------------------------------- /examples/features/fiber_forward/client/trpc_cpp_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | fiber: 4 | - instance_name: fiber_instance 5 | concurrency_hint: 4 6 | scheduling_group_size: 4 7 | reactor_num_per_scheduling_group: 1 -------------------------------------------------------------------------------- /examples/features/trpc_json/client/trpc_cpp_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | fiber: 4 | - instance_name: fiber_instance 5 | concurrency_hint: 4 6 | scheduling_group_size: 4 7 | reactor_num_per_scheduling_group: 1 -------------------------------------------------------------------------------- /examples/features/trpc_noop/client/trpc_cpp_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | fiber: 4 | - instance_name: fiber_instance 5 | concurrency_hint: 4 6 | scheduling_group_size: 4 7 | reactor_num_per_scheduling_group: 1 -------------------------------------------------------------------------------- /examples/features/trpc_stream/client/trpc_cpp_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | fiber: 4 | - instance_name: fiber_instance 5 | concurrency_hint: 4 6 | scheduling_group_size: 4 7 | reactor_num_per_scheduling_group: 1 -------------------------------------------------------------------------------- /trpc/config/codec/common/BUILD: -------------------------------------------------------------------------------- 1 | # Description: trpc-cpp. 2 | 3 | licenses(["notice"]) 4 | 5 | package(default_visibility = ["//visibility:public"]) 6 | 7 | cc_library( 8 | name = "common_codec", 9 | hdrs = ["common_codec.h"], 10 | ) 11 | -------------------------------------------------------------------------------- /examples/features/request_dispatch/client/trpc_cpp_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | fiber: 4 | - instance_name: fiber_instance 5 | concurrency_hint: 4 6 | scheduling_group_size: 4 7 | reactor_num_per_scheduling_group: 1 -------------------------------------------------------------------------------- /examples/features/trpc_attachment/client/trpc_cpp_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | fiber: 4 | - instance_name: fiber_instance 5 | concurrency_hint: 4 6 | scheduling_group_size: 4 7 | reactor_num_per_scheduling_group: 1 -------------------------------------------------------------------------------- /examples/features/trpc_compressor/client/trpc_cpp_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | fiber: 4 | - instance_name: fiber_instance 5 | concurrency_hint: 4 6 | scheduling_group_size: 4 7 | reactor_num_per_scheduling_group: 1 -------------------------------------------------------------------------------- /examples/features/trpc_flatbuffers/client/trpc_cpp_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | fiber: 4 | - instance_name: fiber_instance 5 | concurrency_hint: 4 6 | scheduling_group_size: 4 7 | reactor_num_per_scheduling_group: 1 -------------------------------------------------------------------------------- /examples/features/trpc_transparent/client/trpc_cpp_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | fiber: 4 | - instance_name: fiber_instance 5 | concurrency_hint: 4 6 | scheduling_group_size: 4 7 | reactor_num_per_scheduling_group: 1 -------------------------------------------------------------------------------- /examples/features/http_upload_download/client/trpc_cpp_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | fiber: 4 | - instance_name: fiber_instance 5 | concurrency_hint: 4 6 | scheduling_group_size: 4 7 | reactor_num_per_scheduling_group: 1 -------------------------------------------------------------------------------- /examples/features/thirdparty_protocol/client/trpc_cpp_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | fiber: 4 | - instance_name: fiber_instance 5 | concurrency_hint: 4 6 | scheduling_group_size: 4 7 | reactor_num_per_scheduling_group: 1 -------------------------------------------------------------------------------- /examples/features/trpc_stream_forward/client/trpc_cpp_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | fiber: 4 | - instance_name: fiber_instance 5 | concurrency_hint: 4 6 | scheduling_group_size: 4 7 | reactor_num_per_scheduling_group: 1 -------------------------------------------------------------------------------- /trpc/metrics/prometheus/testing/prometheus_metrics.yaml: -------------------------------------------------------------------------------- 1 | plugins: 2 | metrics: 3 | prometheus: 4 | histogram_module_cfg: 5 | - 1 6 | - 2 7 | - 3 8 | const_labels: 9 | key1: value1 10 | key2: value2 11 | -------------------------------------------------------------------------------- /trpc/proto/testing/helloworld.fbs: -------------------------------------------------------------------------------- 1 | namespace trpc.test.helloworld; 2 | 3 | table FbReply { 4 | message:string; 5 | } 6 | 7 | table FbRequest { 8 | message:string; 9 | } 10 | 11 | rpc_service FbGreeter { 12 | SayHello(FbRequest):FbReply; 13 | } 14 | -------------------------------------------------------------------------------- /examples/features/admin/proxy/forward.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package trpc.test.route; 4 | 5 | import "examples/helloworld/helloworld.proto"; 6 | 7 | service Forward { 8 | rpc Route (trpc.test.helloworld.HelloRequest) returns (trpc.test.helloworld.HelloReply) {} 9 | } -------------------------------------------------------------------------------- /test/end2end/unary/rpcz/conf/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | filegroup( 4 | name = "unit_test_resources", 5 | testonly = 1, 6 | srcs = glob( 7 | ["*.yaml"], 8 | exclude_directories = 0, 9 | ), 10 | ) 11 | -------------------------------------------------------------------------------- /trpc/common/logging/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "trpc_logging", 7 | hdrs = ["trpc_logging.h"], 8 | deps = [ 9 | "//trpc/log:trpc_log", 10 | ], 11 | ) 12 | -------------------------------------------------------------------------------- /trpc/coroutine/fiber/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "runtime", 7 | hdrs = ["runtime.h"], 8 | deps = [ 9 | "//trpc/runtime:fiber_runtime", 10 | ], 11 | ) 12 | -------------------------------------------------------------------------------- /examples/features/trpc_flatbuffers/proxy/greeter.fbs: -------------------------------------------------------------------------------- 1 | namespace trpc.test.helloworld; 2 | 3 | table FbReply { 4 | message:string; 5 | } 6 | 7 | table FbRequest { 8 | message:string; 9 | } 10 | 11 | rpc_service FbGreeter { 12 | SayHello(FbRequest):FbReply; 13 | } 14 | -------------------------------------------------------------------------------- /examples/features/trpc_flatbuffers/server/greeter.fbs: -------------------------------------------------------------------------------- 1 | namespace trpc.test.helloworld; 2 | 3 | table FbReply { 4 | message:string; 5 | } 6 | 7 | table FbRequest { 8 | message:string; 9 | } 10 | 11 | rpc_service FbGreeter { 12 | SayHello(FbRequest):FbReply; 13 | } 14 | -------------------------------------------------------------------------------- /test/end2end/unary/future/conf/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | filegroup( 4 | name = "unit_test_resources", 5 | testonly = 1, 6 | srcs = glob( 7 | ["*.yaml"], 8 | exclude_directories = 0, 9 | ), 10 | ) 11 | -------------------------------------------------------------------------------- /trpc/util/async_io/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "async_io", 7 | hdrs = ["async_io.h"], 8 | deps = [ 9 | "//trpc/runtime/iomodel/async_io", 10 | ], 11 | ) 12 | -------------------------------------------------------------------------------- /trpc/overload_control/common/report_test.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | namespace: informal 3 | env_name: test1 4 | container_name: test_container1 5 | local_ip: 0.0.0.0 6 | coroutine: 7 | enable: false 8 | 9 | plugins: 10 | metrics: 11 | test_metrics: {} 12 | -------------------------------------------------------------------------------- /.github/.codecov.yml: -------------------------------------------------------------------------------- 1 | comment: 2 | layout: "reach,diff,flags,tree" 3 | behavior: default 4 | require_changes: false 5 | 6 | coverage: 7 | status: 8 | project: 9 | default: 10 | informational: true 11 | threshold: 1% 12 | patch: false 13 | patch: false -------------------------------------------------------------------------------- /trpc/auth/testing/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "auth_testing", 7 | hdrs = ["auth_testing.h"], 8 | deps = [ 9 | "//trpc/auth", 10 | "@com_google_googletest//:gtest", 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /trpc/tools/comm/trpc_cpp_options.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package trpc; 4 | 5 | import "google/protobuf/descriptor.proto"; 6 | 7 | extend google.protobuf.MethodOptions { 8 | CppExt cpp_ext = 82001; 9 | } 10 | 11 | message CppExt { 12 | repeated string alias = 1; // support mutiple alias 13 | } -------------------------------------------------------------------------------- /trpc/compressor/testing/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "compressor_testing", 7 | hdrs = [ 8 | "compressor_testing.h", 9 | ], 10 | deps = [ 11 | "//trpc/compressor", 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /examples/helloworld/helloworld.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package trpc.test.helloworld; 4 | 5 | service Greeter { 6 | rpc SayHello (HelloRequest) returns (HelloReply) {} 7 | } 8 | 9 | message HelloRequest { 10 | string msg = 1; 11 | } 12 | 13 | message HelloReply { 14 | string msg = 1; 15 | } 16 | -------------------------------------------------------------------------------- /trpc/metrics/testing/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | exports_files(["metrics.yaml"]) 6 | 7 | cc_library( 8 | name = "metrics_testing", 9 | hdrs = ["metrics_testing.h"], 10 | deps = [ 11 | "//trpc/metrics", 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /trpc/proto/testing/helloworld.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package trpc.test.helloworld; 4 | 5 | service Greeter { 6 | rpc SayHello (HelloRequest) returns (HelloReply) {} 7 | } 8 | 9 | message HelloRequest { 10 | string msg = 1; 11 | } 12 | 13 | message HelloReply { 14 | string msg = 1; 15 | } 16 | -------------------------------------------------------------------------------- /trpc/codec/grpc/http2/testing/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "mock_session", 5 | srcs = [], 6 | hdrs = ["mock_session.h"], 7 | deps = [ 8 | "//trpc/codec/grpc/http2:session", 9 | "@com_google_googletest//:gtest", 10 | ], 11 | ) 12 | -------------------------------------------------------------------------------- /trpc/stream/trpc/testing/BUILD: -------------------------------------------------------------------------------- 1 | # Description: trpc-cpp. 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "trpc_stream_testing", 7 | srcs = [], 8 | hdrs = ["trpc_stream_testing.h"], 9 | deps = [ 10 | "//trpc/codec/trpc:trpc_protocol", 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /examples/features/grpc_stream/common/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "helper", 7 | srcs = ["helper.cc"], 8 | hdrs = ["helper.h"], 9 | deps = [ 10 | "//examples/features/grpc_stream/server:stream_proto", 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /examples/unittest/BUILD: -------------------------------------------------------------------------------- 1 | load("//trpc:trpc.bzl", "trpc_proto_library") 2 | 3 | licenses(["notice"]) 4 | 5 | package(default_visibility = ["//visibility:public"]) 6 | 7 | trpc_proto_library( 8 | name = "helloworld_proto", 9 | srcs = ["helloworld.proto"], 10 | generate_mock_code = True, 11 | use_trpc_plugin = True, 12 | ) 13 | -------------------------------------------------------------------------------- /third_party/com_github_h2o_picohttpparser/picohttpparser.BUILD: -------------------------------------------------------------------------------- 1 | package( 2 | default_visibility = ["//visibility:public"], 3 | ) 4 | 5 | cc_library( 6 | name = "picohttpparser", 7 | srcs = ["picohttpparser.c"], 8 | hdrs = ["picohttpparser.h"], 9 | visibility = [ 10 | "//visibility:public", 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /test/end2end/unary/redis/conf/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | filegroup( 4 | name = "unit_test_resources", 5 | testonly = 1, 6 | srcs = glob( 7 | ["*.yaml"], 8 | exclude_directories = 0, 9 | ), 10 | visibility = [ 11 | "//visibility:public", 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /test/end2end/unary/trpc/conf/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | filegroup( 4 | name = "unit_test_resources", 5 | testonly = 1, 6 | srcs = glob( 7 | ["*.yaml"], 8 | exclude_directories = 0, 9 | ), 10 | visibility = [ 11 | "//visibility:public", 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /test/end2end/unary/tvar/conf/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | filegroup( 4 | name = "unit_test_resources", 5 | testonly = 1, 6 | srcs = glob( 7 | ["*.yaml"], 8 | exclude_directories = 0, 9 | ), 10 | visibility = [ 11 | "//visibility:public", 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /examples/features/trpc_attachment/server/BUILD: -------------------------------------------------------------------------------- 1 | cc_binary( 2 | name = "demo_server", 3 | srcs = ["demo_server.cc"], 4 | deps = [ 5 | "//examples/helloworld:helloworld_proto", 6 | "@com_github_fmtlib_fmt//:fmtlib", 7 | "@trpc_cpp//trpc/common:trpc_app", 8 | "@trpc_cpp//trpc/log:trpc_log", 9 | ], 10 | ) 11 | -------------------------------------------------------------------------------- /examples/unittest/helloworld.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package trpc.test.unittest; 4 | 5 | service Greeter { 6 | // Demo for asynchronous response 7 | rpc SayHello (HelloRequest) returns (HelloReply) {} 8 | } 9 | 10 | message HelloRequest { 11 | string msg = 1; 12 | } 13 | 14 | message HelloReply { 15 | string msg = 1; 16 | } 17 | -------------------------------------------------------------------------------- /test/end2end/gracefully_stop/run_test.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | function check_success { 4 | if [ $1 -ne 0 ]; then 5 | echo "Failed" 6 | exit -1 7 | fi 8 | } 9 | 10 | cd helloworld 11 | chmod +x run_test.sh 12 | ./run_test.sh 13 | check_success $? 14 | 15 | cd ../forward 16 | chmod +x run_test.sh 17 | ./run_test.sh 18 | check_success $? -------------------------------------------------------------------------------- /trpc/config/testing/test.yaml: -------------------------------------------------------------------------------- 1 | plugins: 2 | config: 3 | local_file: 4 | providers: 5 | - name: file1 6 | filename: trpc/config/testing/test_load.yaml 7 | - name: file2 8 | filename: trpc/config/testing/test_load.json 9 | - name: file3 10 | filename: trpc/config/testing/test_load.toml 11 | -------------------------------------------------------------------------------- /test/end2end/unary/fiber/conf/fiber_test/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | filegroup( 4 | name = "unit_test_resources", 5 | testonly = 1, 6 | srcs = glob( 7 | ["*.yaml"], 8 | exclude_directories = 0, 9 | ), 10 | visibility = [ 11 | "//visibility:public", 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /test/end2end/unary/http/conf/http_rpc_test/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | filegroup( 4 | name = "unit_test_resources", 5 | testonly = 1, 6 | srcs = glob( 7 | ["*.yaml"], 8 | exclude_directories = 0, 9 | ), 10 | visibility = [ 11 | "//visibility:public", 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /test/end2end/unary/http/conf/http_test/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | filegroup( 4 | name = "unit_test_resources", 5 | testonly = 1, 6 | srcs = glob( 7 | ["*.yaml"], 8 | exclude_directories = 0, 9 | ), 10 | visibility = [ 11 | "//visibility:public", 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /trpc/naming/common/util/BUILD: -------------------------------------------------------------------------------- 1 | # Description: trpc-cpp. 2 | 3 | licenses(["notice"]) 4 | 5 | package(default_visibility = ["//visibility:public"]) 6 | 7 | cc_library( 8 | name = "utils_help", 9 | srcs = ["utils_help.cc"], 10 | hdrs = ["utils_help.h"], 11 | deps = [ 12 | "//trpc/naming/common:common_defs", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /trpc/transport/client/future/testing/merge_separate_threadmodel.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | default: 4 | - instance_name: default_separate 5 | io_handle_type: separate 6 | io_thread_num: 1 7 | handle_thread_num: 1 8 | - instance_name: default_merge 9 | io_handle_type: merge 10 | io_thread_num: 1 -------------------------------------------------------------------------------- /test/end2end/gracefully_stop/README.md: -------------------------------------------------------------------------------- 1 | ### trpc-cpp gracefully stop end2end testing 2 | 3 | Mainly, it simulates scenarios where the process receives the SIGUSR2 signal (kill -12 pid) in the server (helloworld directory) and relay (forward directory) scenarios. The goal is to check if the process can gracefully exit without crashing and without generating a core dump -------------------------------------------------------------------------------- /test/end2end/stream/trpc/conf/BUILD: -------------------------------------------------------------------------------- 1 | filegroup( 2 | name = "unit_test_resources", 3 | testonly = 1, 4 | srcs = glob( 5 | [ 6 | "async_test/*.yaml", 7 | "sync_test/*.yaml", 8 | ], 9 | exclude_directories = 0, 10 | ), 11 | visibility = [ 12 | "//visibility:public", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /third_party/com_github_tencent_rapidjson/rapidjson.BUILD: -------------------------------------------------------------------------------- 1 | # RapidJSON (rapidjson.org) library. 2 | 3 | package( 4 | default_visibility = ["//visibility:public"], 5 | ) 6 | 7 | cc_library( 8 | name = "rapidjson", 9 | hdrs = glob(["include/rapidjson/**/*.h"]), 10 | defines = ["RAPIDJSON_HAS_STDSTRING=1"], 11 | includes = ["include"], 12 | ) 13 | -------------------------------------------------------------------------------- /test/end2end/unary/future/future.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package trpc.testing.future; 4 | 5 | service Future { 6 | rpc SayHello (TestRequest) returns (TestReply) {} 7 | rpc SayHelloTimeout (TestRequest) returns (TestReply) {} 8 | } 9 | 10 | message TestRequest { 11 | string msg = 1; 12 | } 13 | 14 | message TestReply { 15 | string msg = 1; 16 | } 17 | -------------------------------------------------------------------------------- /trpc/stream/http/async/testing/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "mock_async_stream", 7 | srcs = [], 8 | hdrs = ["mock_async_stream.h"], 9 | deps = [ 10 | "//trpc/stream/http/async:stream", 11 | "@com_google_googletest//:gtest", 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /trpc/tvar/testing/series.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 127.0.0.1 3 | tvar: 4 | window_size: 20 5 | save_series: true 6 | latency_p1: 85 7 | latency_p2: 95 8 | latency_p3: 99 9 | 10 | server: 11 | app: test 12 | server: test_server 13 | bin_path: ./ 14 | conf_path: ./ 15 | data_path: ./ 16 | server_stats_interval: 1000 17 | service: 18 | -------------------------------------------------------------------------------- /trpc/util/buffer/testing/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | proto_library( 6 | name = "message_proto", 7 | srcs = [ 8 | "message.proto", 9 | ], 10 | ) 11 | 12 | cc_proto_library( 13 | name = "cc_message_proto", 14 | deps = [ 15 | ":message_proto", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | Language: Cpp 2 | BasedOnStyle: Google 3 | ColumnLimit: 120 4 | 5 | # Force pointers to the type for C++. 6 | # If `true`, analyze the formatted file for the most common alignment of '&' and '*'. 7 | DerivePointerAlignment: false 8 | PointerAlignment: Left 9 | 10 | # Only sort headers in each include block 11 | SortIncludes: true 12 | IncludeBlocks: Preserve -------------------------------------------------------------------------------- /trpc/tvar/testing/noseries.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 127.0.0.1 3 | tvar: 4 | window_size: 20 5 | save_series: false 6 | latency_p1: 85 7 | latency_p2: 95 8 | latency_p3: 99 9 | 10 | server: 11 | app: test 12 | server: test_server 13 | bin_path: ./ 14 | conf_path: ./ 15 | data_path: ./ 16 | server_stats_interval: 1000 17 | service: 18 | -------------------------------------------------------------------------------- /examples/features/http_rpc/server/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_binary( 6 | name = "http_rpc_server", 7 | srcs = ["http_server.cc"], 8 | linkopts = ["-ldl"], 9 | deps = [ 10 | "//examples/helloworld:greeter_service", 11 | "@trpc_cpp//trpc/common:trpc_app", 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /examples/features/prometheus/proxy/forward.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package trpc.test.route; 4 | 5 | import "examples/helloworld/helloworld.proto"; 6 | 7 | service Forward { 8 | rpc Route (trpc.test.helloworld.HelloRequest) returns (trpc.test.helloworld.HelloReply) {} 9 | 10 | rpc ParallelRoute (trpc.test.helloworld.HelloRequest) returns (trpc.test.helloworld.HelloReply) {} 11 | } -------------------------------------------------------------------------------- /examples/features/trpc_json/run.sh: -------------------------------------------------------------------------------- 1 | bazel build //examples/features/trpc_json/... 2 | 3 | echo "begin" 4 | ./bazel-bin/examples/features/trpc_json/server/demo_server --config=./examples/features/trpc_json/server/trpc_cpp_fiber.yaml & 5 | sleep 1 6 | ./bazel-bin/examples/features/trpc_json/client/client --client_config=./examples/features/trpc_json/client/trpc_cpp_fiber.yaml 7 | killall demo_server 8 | -------------------------------------------------------------------------------- /examples/features/trpc_noop/run.sh: -------------------------------------------------------------------------------- 1 | bazel build //examples/features/trpc_noop/... 2 | 3 | echo "begin" 4 | ./bazel-bin/examples/features/trpc_noop/server/demo_server --config=./examples/features/trpc_noop/server/trpc_cpp_fiber.yaml & 5 | sleep 1 6 | ./bazel-bin/examples/features/trpc_noop/client/client --client_config=./examples/features/trpc_noop/client/trpc_cpp_fiber.yaml 7 | killall demo_server 8 | -------------------------------------------------------------------------------- /trpc/util/log/default/testing/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | exports_files([ 6 | "default_log_test.yaml", 7 | ]) 8 | 9 | cc_library( 10 | name = "mock_sink", 11 | hdrs = ["mock_sink.h"], 12 | deps = [ 13 | "//trpc/util:ref_ptr", 14 | "@com_github_gabime_spdlog//:spdlog", 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | .idea/ 3 | 4 | bazel-* 5 | *.swp 6 | *.o 7 | *.log 8 | *.so 9 | *.a 10 | *.dylib 11 | 12 | CMakeCache.txt 13 | CMakeFiles 14 | CMakeScripts 15 | cmake_third_party/ 16 | cmake-build-debug/ 17 | 18 | build/ 19 | *.pb.h 20 | *.pb.cc 21 | -------------------------------------------------------------------------------- /examples/features/fiber_forward/proxy/forward.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package trpc.test.route; 4 | 5 | import "examples/helloworld/helloworld.proto"; 6 | 7 | service Forward { 8 | rpc Route (trpc.test.helloworld.HelloRequest) returns (trpc.test.helloworld.HelloReply) {} 9 | 10 | rpc ParallelRoute (trpc.test.helloworld.HelloRequest) returns (trpc.test.helloworld.HelloReply) {} 11 | } -------------------------------------------------------------------------------- /examples/features/future_forward/proxy/forward.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package trpc.test.route; 4 | 5 | import "examples/helloworld/helloworld.proto"; 6 | 7 | service Forward { 8 | rpc Route (trpc.test.helloworld.HelloRequest) returns (trpc.test.helloworld.HelloReply) {} 9 | 10 | rpc ParallelRoute (trpc.test.helloworld.HelloRequest) returns (trpc.test.helloworld.HelloReply) {} 11 | } -------------------------------------------------------------------------------- /trpc/stream/http/async/server/testing/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "mock_server_async_stream", 7 | srcs = [], 8 | hdrs = ["mock_server_async_stream.h"], 9 | deps = [ 10 | "//trpc/stream/http/async/server:stream", 11 | "@com_google_googletest//:gtest", 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /test/end2end/unary/fiber/conf/fiber_test/fiber_client.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 127.0.0.1 3 | threadmodel: 4 | fiber: 5 | - instance_name: fiber_instance 6 | concurrency_hint: 8 7 | 8 | client: 9 | service: 10 | - name: fiber_client 11 | selector_name: direct 12 | target: 127.0.0.1:18000 13 | protocol: trpc 14 | network: tcp 15 | conn_type: long -------------------------------------------------------------------------------- /trpc/util/log/testing/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | exports_files([ 6 | "trpc_log_test.yaml", 7 | ]) 8 | 9 | cc_library( 10 | name = "mock_log", 11 | hdrs = [ 12 | "mock_log.h", 13 | ], 14 | deps = [ 15 | "//trpc/util/log", 16 | "//trpc/util/log/default:default_log", 17 | ], 18 | ) 19 | -------------------------------------------------------------------------------- /examples/features/admin/client/trpc_cpp.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | fiber: 4 | - instance_name: fiber_instance 5 | concurrency_hint: 4 6 | scheduling_group_size: 4 7 | reactor_num_per_scheduling_group: 1 8 | 9 | plugins: 10 | log: 11 | default: 12 | - name: default 13 | sinks: 14 | local_file: 15 | filename: client.log 16 | -------------------------------------------------------------------------------- /test/end2end/unary/http/conf/http_test/http_client_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 127.0.0.1 3 | threadmodel: 4 | fiber: 5 | - instance_name: fiber_instance 6 | concurrency_hint: 8 7 | 8 | client: 9 | service: 10 | - name: http_client 11 | selector_name: direct 12 | target: 127.0.0.1:16791 13 | protocol: http 14 | network: tcp 15 | conn_type: long 16 | -------------------------------------------------------------------------------- /test/end2end/unary/http/conf/http_test/http_server_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 127.0.0.1 3 | threadmodel: 4 | fiber: 5 | - instance_name: fiber_instance 6 | concurrency_hint: 8 7 | 8 | server: 9 | app: test 10 | server: test1 11 | service: 12 | - name: default_http_service 13 | network: tcp 14 | ip: 0.0.0.0 15 | port: 16791 16 | protocol: http 17 | -------------------------------------------------------------------------------- /examples/features/trpc_attachment/run.sh: -------------------------------------------------------------------------------- 1 | bazel build //examples/features/trpc_attachment/... 2 | 3 | ./bazel-bin/examples/features/trpc_attachment/server/demo_server --config=./examples/features/trpc_attachment/server/trpc_cpp_fiber.yaml & 4 | sleep 1 5 | ./bazel-bin/examples/features/trpc_attachment/client/client --client_config=./examples/features/trpc_attachment/client/trpc_cpp_fiber.yaml 6 | 7 | killall demo_server 8 | -------------------------------------------------------------------------------- /examples/features/trpc_noop/client/BUILD: -------------------------------------------------------------------------------- 1 | cc_binary( 2 | name = "client", 3 | srcs = ["client.cc"], 4 | deps = [ 5 | "@com_github_gflags_gflags//:gflags", 6 | "@trpc_cpp//trpc/client:make_client_context", 7 | "@trpc_cpp//trpc/client:rpc_service_proxy", 8 | "@trpc_cpp//trpc/common:runtime_manager", 9 | "@trpc_cpp//trpc/client:trpc_client", 10 | ], 11 | ) 12 | -------------------------------------------------------------------------------- /trpc/stream/http/common/testing/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "mock_stream", 7 | srcs = [], 8 | hdrs = ["mock_stream.h"], 9 | deps = [ 10 | "//trpc/stream/http/common:stream", 11 | "//trpc/stream/http/common:stream_handler", 12 | "@com_google_googletest//:gtest", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /trpc/tools/flatbuffers_tool/testing/greeter.fbs: -------------------------------------------------------------------------------- 1 | namespace trpc.test.helloworld; 2 | 3 | table HelloReply { 4 | message:string; 5 | } 6 | 7 | table HelloRequest { 8 | name:string; 9 | } 10 | 11 | table ManyHellosRequest { 12 | name:string; 13 | num_greetings:int; 14 | } 15 | 16 | rpc_service Greeter { 17 | SayHello(HelloRequest):HelloReply; 18 | SayManyHellos(ManyHellosRequest):HelloReply; 19 | } 20 | -------------------------------------------------------------------------------- /trpc/transport/common/ssl/cert/ca/xxops-com-chain/mk_ca_root_key.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | KEY_NAME='root-ca.key' 4 | CERT_NAME='root-ca.crt' 5 | 6 | ## generate rsa key 7 | openssl genrsa -out ${KEY_NAME} 2048 8 | 9 | ## create self-signed the root certificate 10 | openssl req -x509 -new -nodes -key ${KEY_NAME} -sha256 -days 1095 -subj "/C=CN/ST=CA/O=xxops digit cert org" -out ${CERT_NAME} 11 | 12 | 13 | -------------------------------------------------------------------------------- /trpc/tvar/README.md: -------------------------------------------------------------------------------- 1 | This directory contains implementation of tvar. 2 | # Design 3 | - Aimed at write mostly scenario, thread local mechanism is used to imporve write performance, which leadings to poor read performance. 4 | 5 | # Category 6 | - Counter 7 | - Gauge 8 | - Maxer 9 | - Miner 10 | - Averager 11 | - IntRecorder 12 | - Status 13 | - PassiveStatus 14 | - Window 15 | - PerSecond 16 | - LatencyRecorder 17 | -------------------------------------------------------------------------------- /test/end2end/unary/fiber/README.md: -------------------------------------------------------------------------------- 1 | # end2end testing 2 | ## unary 3 | ### fiber 4 | Dode directory organization: 5 | ```text 6 | test/end2end/unary/fiber/ 7 | |-- conf <- same code run with different config 8 | | `-- fiber_test 9 | | |-- BUILD 10 | | |-- fiber_client.yaml 11 | | `-- fiber_server.yaml 12 | |-- fiber.proto 13 | |-- fiber_server.cc 14 | |-- fiber_server.h 15 | `-- fiber_test.cc 16 | ``` -------------------------------------------------------------------------------- /trpc/runtime/common/runtime_info_report/test.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 0.0.0.0 3 | threadmodel: 4 | default: 5 | - instance_name: default_instance 6 | io_handle_type: separate 7 | io_thread_num: 4 8 | handle_thread_num: 4 9 | enable_runtime_report: true 10 | report_runtime_info_interval: 30000 11 | plugins: 12 | metrics: 13 | test_runtime_report: -------------------------------------------------------------------------------- /trpc/transport/server/testing/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "server_transport_testing", 7 | hdrs = ["server_transport_testing.h"], 8 | deps = [ 9 | "//trpc/transport/server:server_transport", 10 | "@com_google_googletest//:gtest", 11 | "@com_google_googletest//:gtest_main", 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /examples/features/trpc_compressor/run.sh: -------------------------------------------------------------------------------- 1 | bazel build //examples/helloworld/... 2 | bazel build //examples/features/trpc_compressor/... 3 | 4 | ./bazel-bin/examples/helloworld/helloworld_svr --config=./examples/helloworld/conf/trpc_cpp_fiber.yaml & 5 | sleep 1 6 | ./bazel-bin/examples/features/trpc_compressor/client/client --client_config=./examples/features/trpc_compressor/client/trpc_cpp_fiber.yaml 7 | 8 | killall helloworld_svr 9 | -------------------------------------------------------------------------------- /test/end2end/unary/redis/conf/redis_server.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 127.0.0.1 3 | threadmodel: 4 | fiber: 5 | - instance_name: fiber_instance 6 | concurrency_hint: 8 7 | 8 | server: 9 | app: test 10 | server: test1 11 | service: 12 | ## for mock a redis-service 13 | - name: mock_redis_service 14 | network: tcp 15 | ip: 0.0.0.0 16 | port: 16790 17 | protocol: trpc 18 | -------------------------------------------------------------------------------- /test/end2end/unary/rpcz/conf/rpcz_real_server_merge.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 0.0.0.0 3 | threadmodel: 4 | default: 5 | - instance_name: default_instance 6 | io_handle_type: merge 7 | io_thread_num: 2 8 | 9 | server: 10 | app: rpcz 11 | server: real 12 | service: 13 | - name: echo_service 14 | protocol: trpc 15 | network: tcp 16 | ip: 0.0.0.0 17 | port: 15002 18 | -------------------------------------------------------------------------------- /examples/features/tvar/client/trpc_cpp_client.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 0.0.0.0 3 | threadmodel: 4 | default: 5 | - instance_name: default_instance 6 | io_handle_type: merge 7 | io_thread_num: 4 8 | 9 | client: 10 | service: 11 | - name: tvar_client 12 | selector_name: direct 13 | target: 127.0.0.1:13001 14 | protocol: trpc 15 | network: tcp 16 | conn_type: long 17 | -------------------------------------------------------------------------------- /trpc/common/coroutine/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "task_executor", 7 | hdrs = ["task_executor.h"], 8 | deps = [ 9 | "//trpc/common:status", 10 | ], 11 | ) 12 | 13 | cc_library( 14 | name = "task_executer", 15 | hdrs = ["task_executer.h"], 16 | deps = [ 17 | ":task_executor", 18 | ], 19 | ) 20 | -------------------------------------------------------------------------------- /trpc/runtime/iomodel/reactor/testing/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "mock_connection_testing", 7 | hdrs = ["mock_connection_testing.h"], 8 | deps = [ 9 | "//trpc/runtime/iomodel/reactor/common:connection", 10 | "@com_google_googletest//:gtest", 11 | "@com_google_googletest//:gtest_main", 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /trpc/runtime/threadmodel/testing/separate.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | default: 4 | - instance_name: default_instance 5 | io_handle_type: separate 6 | io_thread_num: 8 7 | handle_thread_num: 2 8 | handle_thread_task_queue_size: 10240 9 | scheduling: 10 | scheduling_name: non_fiber 11 | local_queue_size: 10240 12 | max_timer_size: 20480 13 | -------------------------------------------------------------------------------- /examples/features/rpcz/proxy/rpcz.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package trpc.examples.rpcz; 4 | 5 | import "examples/helloworld/helloworld.proto"; 6 | 7 | service Rpcz { 8 | // Client rpcz / server rpcz. 9 | rpc Normal (trpc.test.helloworld.HelloRequest) returns (trpc.test.helloworld.HelloReply) {} 10 | // Route rpcz. 11 | rpc Route (trpc.test.helloworld.HelloRequest) returns (trpc.test.helloworld.HelloReply) {} 12 | } 13 | -------------------------------------------------------------------------------- /test/end2end/unary/fiber/conf/fiber_test/fiber_server.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 127.0.0.1 3 | threadmodel: 4 | fiber: 5 | - instance_name: fiber_instance 6 | concurrency_hint: 8 7 | scheduling_group_size: 4 8 | 9 | server: 10 | app: test 11 | server: test1 12 | service: 13 | - name: fiber_service 14 | network: tcp 15 | ip: 127.0.0.1 16 | port: 18000 17 | protocol: trpc 18 | -------------------------------------------------------------------------------- /test/end2end/unary/redis/conf/redis_client_merge.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 127.0.0.1 3 | threadmodel: 4 | default: 5 | - instance_name: default_instance 6 | io_handle_type: merge 7 | io_thread_num: 8 8 | 9 | client: 10 | service: 11 | - name: redis_client 12 | selector_name: direct 13 | target: 0.0.0.0:6379 14 | protocol: redis 15 | network: tcp 16 | conn_type: long 17 | -------------------------------------------------------------------------------- /trpc/util/testing/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | load("@rules_cc//cc:defs.bzl", "cc_proto_library") 6 | load("@rules_proto//proto:defs.bzl", "proto_library") 7 | 8 | cc_proto_library( 9 | name = "testjson_cc_proto", 10 | deps = [":testjson_proto"], 11 | ) 12 | 13 | proto_library( 14 | name = "testjson_proto", 15 | srcs = ["testjson.proto"], 16 | ) 17 | -------------------------------------------------------------------------------- /test/end2end/unary/http/conf/http_test/http_server_merge.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 127.0.0.1 3 | threadmodel: 4 | default: 5 | - instance_name: default_instance 6 | io_handle_type: merge 7 | io_thread_num: 8 8 | 9 | server: 10 | app: test 11 | server: test1 12 | service: 13 | - name: default_http_service 14 | network: tcp 15 | ip: 0.0.0.0 16 | port: 16789 17 | protocol: http 18 | -------------------------------------------------------------------------------- /test/end2end/unary/http/conf/https_test/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | filegroup( 4 | name = "unit_test_resources", 5 | testonly = 1, 6 | srcs = glob( 7 | [ 8 | "*.yaml", 9 | "*.pem", 10 | "ca*/server.*", 11 | ], 12 | exclude_directories = 0, 13 | ), 14 | visibility = [ 15 | "//visibility:public", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /test/end2end/unary/redis/conf/redis_client_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 127.0.0.1 3 | coroutine: 4 | enable: true 5 | threadmodel: 6 | fiber: 7 | - instance_name: fiber_instance 8 | concurrency_hint: 8 9 | 10 | client: 11 | service: 12 | - name: redis_client 13 | selector_name: direct 14 | target: 0.0.0.0:6379 15 | protocol: redis 16 | network: tcp 17 | conn_type: long 18 | -------------------------------------------------------------------------------- /test/end2end/unary/http/conf/http_rpc_test/http_server_merge.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 127.0.0.1 3 | threadmodel: 4 | default: 5 | - instance_name: default_instance 6 | io_handle_type: merge 7 | io_thread_num: 8 8 | 9 | server: 10 | app: test 11 | server: test1 12 | service: 13 | - name: http_rpc_service 14 | network: tcp 15 | ip: 0.0.0.0 16 | port: 16792 17 | protocol: http 18 | 19 | -------------------------------------------------------------------------------- /test/end2end/unary/http/conf/http_test/http_client_merge.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 127.0.0.1 3 | threadmodel: 4 | default: 5 | - instance_name: default_instance 6 | io_handle_type: merge 7 | io_thread_num: 8 8 | 9 | client: 10 | service: 11 | - name: http_client 12 | selector_name: direct 13 | target: 127.0.0.1:16789 14 | protocol: http 15 | network: tcp 16 | conn_type: long 17 | -------------------------------------------------------------------------------- /examples/features/thirdparty_protocol/run.sh: -------------------------------------------------------------------------------- 1 | bazel build //examples/features/thirdparty_protocol/... 2 | 3 | echo "begin" 4 | ./bazel-bin/examples/features/thirdparty_protocol/server/demo_server --config=./examples/features/thirdparty_protocol/server/trpc_cpp_fiber.yaml & 5 | sleep 1 6 | ./bazel-bin/examples/features/thirdparty_protocol/client/client --client_config=./examples/features/thirdparty_protocol/client/trpc_cpp_fiber.yaml 7 | killall demo_server 8 | -------------------------------------------------------------------------------- /examples/features/trpc_json/client/BUILD: -------------------------------------------------------------------------------- 1 | cc_binary( 2 | name = "client", 3 | srcs = ["client.cc"], 4 | deps = [ 5 | "@com_github_gflags_gflags//:gflags", 6 | "@com_github_tencent_rapidjson//:rapidjson", 7 | "@trpc_cpp//trpc/client:make_client_context", 8 | "@trpc_cpp//trpc/client:rpc_service_proxy", 9 | "@trpc_cpp//trpc/common:runtime_manager", 10 | "@trpc_cpp//trpc/client:trpc_client", 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /trpc/client/grpc/testing/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | exports_files(["grpc_fiber.yaml"]) 6 | 7 | 8 | cc_library( 9 | name = "grpc_client_call_testing", 10 | srcs = ["grpc_client_call_testing.cc"], 11 | hdrs = ["grpc_client_call_testing.h"], 12 | deps = [ 13 | "//trpc/client:make_client_context", 14 | "//trpc/proto/testing:helloworld_proto", 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /test/end2end/unary/redis/conf/redis_client_separate.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 127.0.0.1 3 | threadmodel: 4 | default: 5 | - instance_name: default_instance 6 | io_handle_type: separate 7 | io_thread_num: 2 8 | handle_thread_num: 4 9 | 10 | client: 11 | service: 12 | - name: redis_client 13 | selector_name: direct 14 | target: 0.0.0.0:6379 15 | protocol: redis 16 | network: tcp 17 | conn_type: long 18 | -------------------------------------------------------------------------------- /trpc/runtime/common/stats/server_stats.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 127.0.0.1 3 | threadmodel: 4 | default: 5 | - instance_name: default_instance 6 | io_handle_type: merge 7 | io_thread_num: 1 8 | 9 | server: 10 | app: test 11 | server: test_server 12 | bin_path: ./ 13 | conf_path: ./ 14 | data_path: ./ 15 | server_stats_interval: 1000 16 | service: 17 | plugins: 18 | metrics: 19 | test_server_stats: 20 | param1: 10000 21 | -------------------------------------------------------------------------------- /test/end2end/unary/http/conf/http_rpc_test/http_server_separate.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 127.0.0.1 3 | threadmodel: 4 | default: 5 | - instance_name: default_instance 6 | io_handle_type: separate 7 | io_thread_num: 2 8 | handle_thread_num: 4 9 | 10 | server: 11 | app: test 12 | server: test1 13 | service: 14 | - name: http_rpc_service 15 | network: tcp 16 | ip: 0.0.0.0 17 | port: 16793 18 | protocol: http 19 | -------------------------------------------------------------------------------- /test/end2end/unary/http/conf/http_test/http_server_separate.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 127.0.0.1 3 | threadmodel: 4 | default: 5 | - instance_name: default_instance 6 | io_handle_type: separate 7 | io_thread_num: 2 8 | handle_thread_num: 4 9 | 10 | server: 11 | app: test 12 | server: test1 13 | service: 14 | - name: default_http_service 15 | network: tcp 16 | ip: 0.0.0.0 17 | port: 16790 18 | protocol: http 19 | -------------------------------------------------------------------------------- /trpc/serialization/testing/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | load("@rules_cc//cc:defs.bzl", "cc_proto_library") 6 | load("@rules_proto//proto:defs.bzl", "proto_library") 7 | 8 | cc_proto_library( 9 | name = "test_serialization_cc_proto", 10 | deps = [":test_serialization_proto"], 11 | ) 12 | 13 | proto_library( 14 | name = "test_serialization_proto", 15 | srcs = ["test_serialization.proto"], 16 | ) 17 | -------------------------------------------------------------------------------- /examples/features/https/cert/server_dhparam.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN DH PARAMETERS----- 2 | MIIBCAKCAQEAnMcSkTzUn1MrECQqZWO4/PsOlpmScZ0zGtKueDanUtSNZfVymkqi 3 | 5SdLefAocDpvbdP5caGpAGrVRxAk3M6Qw4fl05cCoJNAHBRDiDpRq6Py1HbNJ6D0 4 | QZUtZMt3ZaGGTKIo5uk5EoPaxxyJG/2TvEgkn25TEJyuP8qE82Ou5s/Gv7Z4kC9i 5 | yyKZXVbYc/YKkpz5u0pAnVwjYLMbHZ+W/hTI6zqv7UF3YM4Kpc9Z86HOZxxPwLqA 6 | /NBNlMj9GgwODKiiK+pYSY58JO6ApGmwVrry6Mi9tCKHWH/3iHdaypcA5SaGhDHL 7 | 5JSkeSQhsDh1aLaSZP4bwjCo8S+uyJyEmwIBAg== 8 | -----END DH PARAMETERS----- 9 | -------------------------------------------------------------------------------- /test/end2end/unary/http/conf/http_test/http_client_separate.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 127.0.0.1 3 | threadmodel: 4 | default: 5 | - instance_name: default_instance 6 | io_handle_type: separate 7 | io_thread_num: 2 8 | handle_thread_num: 4 9 | 10 | client: 11 | service: 12 | - name: http_client 13 | selector_name: direct 14 | target: 127.0.0.1:16790 15 | protocol: http 16 | network: tcp 17 | conn_type: long 18 | -------------------------------------------------------------------------------- /third_party/com_github_nghttp2_nghttp2/nghttp2.BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "nghttp2", 7 | srcs = glob( 8 | [ 9 | "lib/**/*.c", 10 | ], 11 | exclude = ["lib/**/*_test.c"], 12 | ), 13 | hdrs = glob([ 14 | "lib/includes/**/*.h", 15 | "lib/**/*.h", 16 | ]), 17 | includes = ["lib/includes"], 18 | linkstatic = 1, 19 | ) 20 | -------------------------------------------------------------------------------- /test/end2end/unary/http/conf/https_test/dhparam.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN DH PARAMETERS----- 2 | MIIBCAKCAQEAnMcSkTzUn1MrECQqZWO4/PsOlpmScZ0zGtKueDanUtSNZfVymkqi 3 | 5SdLefAocDpvbdP5caGpAGrVRxAk3M6Qw4fl05cCoJNAHBRDiDpRq6Py1HbNJ6D0 4 | QZUtZMt3ZaGGTKIo5uk5EoPaxxyJG/2TvEgkn25TEJyuP8qE82Ou5s/Gv7Z4kC9i 5 | yyKZXVbYc/YKkpz5u0pAnVwjYLMbHZ+W/hTI6zqv7UF3YM4Kpc9Z86HOZxxPwLqA 6 | /NBNlMj9GgwODKiiK+pYSY58JO6ApGmwVrry6Mi9tCKHWH/3iHdaypcA5SaGhDHL 7 | 5JSkeSQhsDh1aLaSZP4bwjCo8S+uyJyEmwIBAg== 8 | -----END DH PARAMETERS----- 9 | -------------------------------------------------------------------------------- /trpc/transport/common/ssl/cert/server_dhparam.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN DH PARAMETERS----- 2 | MIIBCAKCAQEAnMcSkTzUn1MrECQqZWO4/PsOlpmScZ0zGtKueDanUtSNZfVymkqi 3 | 5SdLefAocDpvbdP5caGpAGrVRxAk3M6Qw4fl05cCoJNAHBRDiDpRq6Py1HbNJ6D0 4 | QZUtZMt3ZaGGTKIo5uk5EoPaxxyJG/2TvEgkn25TEJyuP8qE82Ou5s/Gv7Z4kC9i 5 | yyKZXVbYc/YKkpz5u0pAnVwjYLMbHZ+W/hTI6zqv7UF3YM4Kpc9Z86HOZxxPwLqA 6 | /NBNlMj9GgwODKiiK+pYSY58JO6ApGmwVrry6Mi9tCKHWH/3iHdaypcA5SaGhDHL 7 | 5JSkeSQhsDh1aLaSZP4bwjCo8S+uyJyEmwIBAg== 8 | -----END DH PARAMETERS----- 9 | -------------------------------------------------------------------------------- /trpc/transport/common/ssl/cert/xxops-com.dhparam: -------------------------------------------------------------------------------- 1 | -----BEGIN DH PARAMETERS----- 2 | MIIBCAKCAQEAnMcSkTzUn1MrECQqZWO4/PsOlpmScZ0zGtKueDanUtSNZfVymkqi 3 | 5SdLefAocDpvbdP5caGpAGrVRxAk3M6Qw4fl05cCoJNAHBRDiDpRq6Py1HbNJ6D0 4 | QZUtZMt3ZaGGTKIo5uk5EoPaxxyJG/2TvEgkn25TEJyuP8qE82Ou5s/Gv7Z4kC9i 5 | yyKZXVbYc/YKkpz5u0pAnVwjYLMbHZ+W/hTI6zqv7UF3YM4Kpc9Z86HOZxxPwLqA 6 | /NBNlMj9GgwODKiiK+pYSY58JO6ApGmwVrry6Mi9tCKHWH/3iHdaypcA5SaGhDHL 7 | 5JSkeSQhsDh1aLaSZP4bwjCo8S+uyJyEmwIBAg== 8 | -----END DH PARAMETERS----- 9 | -------------------------------------------------------------------------------- /trpc/overload_control/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "overload_control_defs", 7 | hdrs = ["overload_control_defs.h"], 8 | defines = [] + 9 | select({ 10 | "//trpc:trpc_include_overload_control": ["TRPC_BUILD_INCLUDE_OVERLOAD_CONTROL"], 11 | "//conditions:default": [], 12 | }), 13 | visibility = ["//visibility:public"], 14 | ) 15 | -------------------------------------------------------------------------------- /trpc/config/testing/test_load.toml: -------------------------------------------------------------------------------- 1 | title = "TOML TEST" 2 | 3 | [owner] 4 | name = "John Doe" 5 | dob = "1979-05-27T07:32:00-08:00" # First-class dates 6 | 7 | [database] 8 | server = "192.168.1.1" 9 | ports = [ 8001, 8001, 8002 ] 10 | connection_max = 5000 11 | enabled = true 12 | 13 | [servers] 14 | 15 | # Indentation (tabs and/or spaces) is allowed but not required 16 | [servers.alpha] 17 | ip = "10.0.0.1" 18 | dc = "eqdc10" 19 | 20 | [servers.beta] 21 | ip = "10.0.0.2" 22 | dc = "eqdc10" 23 | -------------------------------------------------------------------------------- /examples/features/admin/client/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_binary( 6 | name = "client", 7 | srcs = ["client.cc"], 8 | deps = [ 9 | "//examples/features/admin/proxy:forward_proto", 10 | "@com_github_gflags_gflags//:gflags", 11 | "@trpc_cpp//trpc/client:make_client_context", 12 | "@trpc_cpp//trpc/client:trpc_client", 13 | "@trpc_cpp//trpc/common:runtime_manager", 14 | ], 15 | ) 16 | -------------------------------------------------------------------------------- /examples/features/trpc_attachment/client/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_binary( 4 | name = "client", 5 | srcs = ["client.cc"], 6 | linkopts = ["-ldl"], 7 | deps = [ 8 | "//examples/helloworld:helloworld_proto", 9 | "@com_github_gflags_gflags//:gflags", 10 | "@trpc_cpp//trpc/client:make_client_context", 11 | "@trpc_cpp//trpc/client:trpc_client", 12 | "@trpc_cpp//trpc/common:runtime_manager", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /examples/features/trpc_compressor/client/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_binary( 4 | name = "client", 5 | srcs = ["client.cc"], 6 | linkopts = ["-ldl"], 7 | deps = [ 8 | "//examples/helloworld:helloworld_proto", 9 | "@com_github_gflags_gflags//:gflags", 10 | "@trpc_cpp//trpc/client:make_client_context", 11 | "@trpc_cpp//trpc/client:trpc_client", 12 | "@trpc_cpp//trpc/common:runtime_manager", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /test/end2end/unary/rpcz/conf/rpcz_real_server_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 0.0.0.0 3 | threadmodel: 4 | # Just cooperate with proxy_fiber, real server no need to run in fiber. 5 | default: 6 | - instance_name: default_instance 7 | io_handle_type: merge 8 | io_thread_num: 2 9 | 10 | server: 11 | app: rpcz 12 | server: real 13 | service: 14 | - name: echo_service 15 | protocol: trpc 16 | network: tcp 17 | ip: 0.0.0.0 18 | port: 15006 19 | -------------------------------------------------------------------------------- /trpc/transport/common/ssl/cert/ca/xxops-com-chain/xxops-com.dhparam: -------------------------------------------------------------------------------- 1 | -----BEGIN DH PARAMETERS----- 2 | MIIBCAKCAQEAnMcSkTzUn1MrECQqZWO4/PsOlpmScZ0zGtKueDanUtSNZfVymkqi 3 | 5SdLefAocDpvbdP5caGpAGrVRxAk3M6Qw4fl05cCoJNAHBRDiDpRq6Py1HbNJ6D0 4 | QZUtZMt3ZaGGTKIo5uk5EoPaxxyJG/2TvEgkn25TEJyuP8qE82Ou5s/Gv7Z4kC9i 5 | yyKZXVbYc/YKkpz5u0pAnVwjYLMbHZ+W/hTI6zqv7UF3YM4Kpc9Z86HOZxxPwLqA 6 | /NBNlMj9GgwODKiiK+pYSY58JO6ApGmwVrry6Mi9tCKHWH/3iHdaypcA5SaGhDHL 7 | 5JSkeSQhsDh1aLaSZP4bwjCo8S+uyJyEmwIBAg== 8 | -----END DH PARAMETERS----- 9 | -------------------------------------------------------------------------------- /examples/features/trpc_transparent/client/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_binary( 4 | name = "client", 5 | srcs = ["client.cc"], 6 | linkopts = ["-ldl"], 7 | deps = [ 8 | "//examples/helloworld:helloworld_proto", 9 | "@com_github_gflags_gflags//:gflags", 10 | "@trpc_cpp//trpc/client:make_client_context", 11 | "@trpc_cpp//trpc/client:trpc_client", 12 | "@trpc_cpp//trpc/common:runtime_manager", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /test/end2end/unary/rpcz/conf/rpcz_real_server_separate.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 0.0.0.0 3 | threadmodel: 4 | # Just cooperate with proxy_fiber, real server no need to run in separate. 5 | default: 6 | - instance_name: default_instance 7 | io_handle_type: merge 8 | io_thread_num: 2 9 | 10 | server: 11 | app: rpcz 12 | server: real 13 | service: 14 | - name: echo_service 15 | protocol: trpc 16 | network: tcp 17 | ip: 0.0.0.0 18 | port: 15004 19 | -------------------------------------------------------------------------------- /test/end2end/unary/trpc/trpc_test.fbs: -------------------------------------------------------------------------------- 1 | namespace trpc.testing.unarytrpc; 2 | 3 | table FbsResponse { 4 | message:string; 5 | } 6 | 7 | enum FbsTestCaseType: byte { 8 | FORMAL = 0, // response normally 9 | INVALID_DATA = 1, // response with invalid data 10 | INVALID_TYPE = 2 // response with invalid data type 11 | } 12 | 13 | table FbsRequest { 14 | test_case_type:FbsTestCaseType; 15 | message:string; 16 | } 17 | 18 | rpc_service FbsTest { 19 | TestFbs(FbsRequest):FbsResponse; 20 | } 21 | -------------------------------------------------------------------------------- /examples/features/filter/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # build 4 | bazel build //examples/features/filter/server:demo_server 5 | bazel build //examples/features/filter/client:demo_client 6 | 7 | # start server and client 8 | ./bazel-bin/examples/features/filter/server/demo_server --config=./examples/features/filter/server/trpc_cpp_fiber.yaml & 9 | sleep 1 10 | ./bazel-bin/examples/features/filter/client/demo_client --client_config=./examples/features/filter/client/trpc_cpp_separate.yaml 11 | 12 | killall demo_server -------------------------------------------------------------------------------- /trpc/admin/perl_tools/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "pprof", 7 | srcs = ["pprof.cc"], 8 | hdrs = ["pprof.h"], 9 | ) 10 | 11 | cc_test( 12 | name = "pprof_test", 13 | srcs = ["pprof_test.cc"], 14 | linkopts = [ 15 | "-ldl", 16 | ], 17 | deps = [ 18 | ":pprof", 19 | "@com_google_googletest//:gtest", 20 | "@com_google_googletest//:gtest_main", 21 | ], 22 | ) 23 | -------------------------------------------------------------------------------- /trpc/naming/common/util/loadbalance/polling/BUILD: -------------------------------------------------------------------------------- 1 | # Description: trpc-cpp. 2 | 3 | licenses(["notice"]) 4 | 5 | package(default_visibility = ["//visibility:public"]) 6 | 7 | cc_library( 8 | name = "polling_load_balance", 9 | srcs = ["polling_load_balance.cc"], 10 | hdrs = ["polling_load_balance.h"], 11 | visibility = [ 12 | "//visibility:public", 13 | ], 14 | deps = [ 15 | "//trpc/naming:load_balance_factory", 16 | "//trpc/util/log:logging", 17 | ], 18 | ) 19 | -------------------------------------------------------------------------------- /trpc/tools/comm/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "utils", 7 | srcs = ["utils.cc"], 8 | hdrs = ["utils.h"], 9 | deps = [ 10 | "@com_google_protobuf//:protobuf", 11 | "@com_google_protobuf//:protoc_lib", 12 | ], 13 | ) 14 | 15 | proto_library( 16 | name = "trpc_cpp_options_proto", 17 | srcs = ["trpc_cpp_options.proto"], 18 | deps = ["@com_google_protobuf//:descriptor_proto"], 19 | ) 20 | -------------------------------------------------------------------------------- /examples/features/https/server/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_binary( 6 | name = "https_server", 7 | srcs = ["https_server.cc"], 8 | linkopts = ["-ldl"], 9 | deps = [ 10 | "@trpc_cpp//trpc/common:trpc_app", 11 | "@trpc_cpp//trpc/server:http_service", 12 | "@trpc_cpp//trpc/util/http:http_handler", 13 | "@trpc_cpp//trpc/util/http:routes", 14 | "@trpc_cpp//trpc/util/log:logging", 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /examples/features/rpcz/client/trpc_cpp_client.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 0.0.0.0 3 | enable_version_report: false 4 | threadmodel: 5 | default: 6 | - instance_name: default_instance 7 | io_handle_type: merge 8 | io_thread_num: 4 9 | 10 | client: 11 | service: 12 | - name: rpcz_client 13 | selector_name: direct 14 | target: 127.0.0.1:15001 15 | protocol: trpc 16 | network: tcp 17 | conn_type: long 18 | is_conn_complex: true 19 | timeout: 1000 20 | -------------------------------------------------------------------------------- /examples/features/trpc_json/server/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_binary( 4 | name = "demo_server", 5 | srcs = ["demo_server.cc"], 6 | linkopts = [ 7 | "-ldl", 8 | ], 9 | deps = [ 10 | "@trpc_cpp//trpc/common:trpc_app", 11 | "@trpc_cpp//trpc/log:trpc_log", 12 | "@trpc_cpp//trpc/server:rpc_method_handler", 13 | "@trpc_cpp//trpc/server:rpc_service_impl", 14 | "@trpc_cpp//trpc/server:rpc_service_method", 15 | ], 16 | ) -------------------------------------------------------------------------------- /examples/features/trpc_noop/server/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_binary( 4 | name = "demo_server", 5 | srcs = ["demo_server.cc"], 6 | linkopts = [ 7 | "-ldl", 8 | ], 9 | deps = [ 10 | "@trpc_cpp//trpc/common:trpc_app", 11 | "@trpc_cpp//trpc/log:trpc_log", 12 | "@trpc_cpp//trpc/server:rpc_method_handler", 13 | "@trpc_cpp//trpc/server:rpc_service_impl", 14 | "@trpc_cpp//trpc/server:rpc_service_method", 15 | ], 16 | ) -------------------------------------------------------------------------------- /test/end2end/unary/future/README.md: -------------------------------------------------------------------------------- 1 | # end2end testing 2 | ## unary 3 | ### future 4 | Directory tree as shown below: 5 | ```text 6 | test/end2end/unary/future 7 | -- conf 8 | | |-- BUILD 9 | | |-- future_client_merge.yaml 10 | | |-- future_client_separate.yaml 11 | | |-- future_server_merge.yaml 12 | | |-- future_server_separate.yaml 13 | |-- BUILD 14 | |-- future_fixture.cc 15 | |-- future_fixture.h 16 | |-- future_server.cc 17 | |-- future_server.h 18 | |-- future_test.cc 19 | |-- future.proto 20 | |-- README.md 21 | ``` 22 | -------------------------------------------------------------------------------- /test/end2end/unary/trpc/common_funcs.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023, Tencent Inc. 2 | // All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "trpc/coroutine/fiber.h" 7 | #include "trpc/runtime/runtime.h" 8 | 9 | namespace trpc::testing { 10 | 11 | void SleepFor(uint32_t ms) { 12 | if (::trpc::runtime::IsInFiberRuntime()) { 13 | ::trpc::FiberSleepFor(std::chrono::milliseconds(ms)); 14 | } else { 15 | std::this_thread::sleep_for(std::chrono::milliseconds(ms)); 16 | } 17 | } 18 | 19 | } // namespace trpc::testing 20 | -------------------------------------------------------------------------------- /trpc/codec/trpc/testing/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "trpc_protocol_testing", 7 | hdrs = ["trpc_protocol_testing.h"], 8 | deps = [ 9 | "//trpc/codec/trpc:trpc_protocol", 10 | "//trpc/serialization:serialization_factory", 11 | "//trpc/serialization:serialization_type", 12 | "//trpc/util:ref_ptr", 13 | "//trpc/util/buffer", 14 | "//trpc/util/flatbuffers:trpc_fbs", 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /trpc/util/hash_util.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/util/algorithm/hash.h" 17 | -------------------------------------------------------------------------------- /trpc/util/http/reply.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/util/http/response.h" 17 | -------------------------------------------------------------------------------- /trpc/log/printf_like.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/util/log/printf_like.h" 17 | -------------------------------------------------------------------------------- /trpc/log/python_like.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/util/log/python_like.h" 17 | -------------------------------------------------------------------------------- /trpc/log/stream_like.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/util/log/stream_like.h" 17 | -------------------------------------------------------------------------------- /trpc/runtime/threadmodel/testing/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | exports_files(["separate.yaml"]) 6 | 7 | exports_files(["fiber.yaml"]) 8 | 9 | exports_files(["merge.yaml"]) 10 | 11 | cc_library( 12 | name = "thread_model_testing", 13 | hdrs = ["thread_model_testing.h"], 14 | deps = [ 15 | "//trpc/runtime/threadmodel:thread_model", 16 | "@com_google_googletest//:gtest", 17 | "@com_google_googletest//:gtest_main", 18 | ], 19 | ) 20 | -------------------------------------------------------------------------------- /test/end2end/stream/trpc/conf/sync_test/async_stream_server.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | default: 4 | - instance_name: default_instance 5 | io_handle_type: merge 6 | io_thread_num: 4 7 | 8 | server: 9 | app: testing 10 | server: stream_test 11 | service: 12 | - name: trpc.testing.stream_test.AsyncStreamService 13 | protocol: trpc 14 | port: 14217 15 | - name: trpc.testing.stream_test.AsyncStreamServiceConnIdle 16 | protocol: trpc 17 | port: 14219 18 | idle_time: 2000 19 | -------------------------------------------------------------------------------- /trpc/common/logging/trpc_logging.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/log/trpc_log.h" 17 | -------------------------------------------------------------------------------- /examples/features/trpc_flatbuffers/client/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_binary( 4 | name = "client", 5 | srcs = ["client.cc"], 6 | deps = [ 7 | "//examples/features/trpc_flatbuffers/proxy:forward_fbs", 8 | "@com_github_gflags_gflags//:gflags", 9 | "@trpc_cpp//trpc/client:client_context", 10 | "@trpc_cpp//trpc/client:make_client_context", 11 | "@trpc_cpp//trpc/common:runtime_manager", 12 | "@trpc_cpp//trpc/client:trpc_client", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /examples/features/trpc_stream_forward/proxy/stream_forward.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package trpc.test.helloworld; 4 | 5 | import "examples/features/trpc_stream/server/stream.proto"; 6 | 7 | service StreamForward { 8 | // Client streaming 9 | rpc ClientStreamSayHello (stream HelloRequest) returns (HelloReply) {} 10 | 11 | // Server streaming 12 | rpc ServerStreamSayHello (HelloRequest) returns (stream HelloReply) {} 13 | 14 | // Bidi streaming 15 | rpc BidiStreamSayHello (stream HelloRequest) returns (stream HelloReply) {} 16 | } -------------------------------------------------------------------------------- /test/end2end/stream/trpc/conf/async_test/async_stream_server.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | default: 4 | - instance_name: default_instance 5 | io_handle_type: merge 6 | io_thread_num: 4 7 | 8 | server: 9 | app: testing 10 | server: stream_test 11 | service: 12 | - name: trpc.testing.stream_test.AsyncStreamService 13 | protocol: trpc 14 | port: 13217 15 | - name: trpc.testing.stream_test.AsyncStreamServiceConnIdle 16 | protocol: trpc 17 | port: 13219 18 | idle_time: 2000 19 | -------------------------------------------------------------------------------- /test/end2end/unary/future/conf/future_server_merge.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 0.0.0.0 3 | threadmodel: 4 | default: 5 | - instance_name: default_instance 6 | io_handle_type: merge 7 | io_thread_num: 4 8 | 9 | server: 10 | app: test 11 | server: test1 12 | service: 13 | - name: tcp_service 14 | protocol: trpc 15 | network: tcp 16 | ip: 0.0.0.0 17 | port: 14001 18 | - name: udp_service 19 | protocol: trpc 20 | network: udp 21 | ip: 0.0.0.0 22 | port: 14003 23 | -------------------------------------------------------------------------------- /trpc/runtime/threadmodel/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "thread_model", 7 | hdrs = ["thread_model.h"], 8 | deps = [ 9 | "//trpc/runtime/threadmodel/common:msg_task", 10 | ], 11 | ) 12 | 13 | cc_library( 14 | name = "thread_model_manager", 15 | srcs = ["thread_model_manager.cc"], 16 | hdrs = ["thread_model_manager.h"], 17 | deps = [ 18 | ":thread_model", 19 | "//trpc/util/log:logging", 20 | ], 21 | ) 22 | -------------------------------------------------------------------------------- /trpc/util/lockfree_queue.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/util/queue/lockfree_queue.h" 17 | -------------------------------------------------------------------------------- /examples/features/trpc_json/run_cmake.sh: -------------------------------------------------------------------------------- 1 | mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j8 && cd - 2 | mkdir -p examples/features/trpc_json/build && cd examples/features/trpc_json/build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j8 && cd - 3 | 4 | echo "begin" 5 | examples/features/trpc_json/build/demo_server --config=./examples/features/trpc_json/server/trpc_cpp_fiber.yaml & 6 | sleep 1 7 | examples/features/trpc_json/build/client --client_config=./examples/features/trpc_json/client/trpc_cpp_fiber.yaml 8 | killall demo_server 9 | -------------------------------------------------------------------------------- /examples/features/trpc_noop/run_cmake.sh: -------------------------------------------------------------------------------- 1 | mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j8 && cd - 2 | mkdir -p examples/features/trpc_noop/build && cd examples/features/trpc_noop/build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j8 && cd - 3 | 4 | echo "begin" 5 | examples/features/trpc_noop/build/demo_server --config=./examples/features/trpc_noop/server/trpc_cpp_fiber.yaml & 6 | sleep 1 7 | examples/features/trpc_noop/build/client --client_config=./examples/features/trpc_noop/client/trpc_cpp_fiber.yaml 8 | killall demo_server 9 | -------------------------------------------------------------------------------- /trpc/runtime/init_runtime.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | // for compatible 17 | #include "trpc/runtime/runtime.h" 18 | -------------------------------------------------------------------------------- /trpc/server/rpc_method_handler.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/server/rpc/rpc_method_handler.h" 17 | -------------------------------------------------------------------------------- /trpc/server/rpc_service_method.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/server/rpc/rpc_service_method.h" 17 | -------------------------------------------------------------------------------- /trpc/transport/client/future/README.md: -------------------------------------------------------------------------------- 1 | This directory contains implementation of future transport. 2 | # Design 3 | - Every client service has its own FutureTransport instance. 4 | - Every reactor of thread model instance has its own FutureTransportAdaptor, in order to avoid cache bouncing. 5 | - FutureConnectorGroup is used to manage all the connections current client service reactor to a backend host. 6 | - Timing wheel is used to improve performance of request timeout. 7 | 8 | # Category 9 | - connection complex 10 | - connection pool 11 | - pipeline 12 | -------------------------------------------------------------------------------- /trpc/util/doubly_linked_list.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/util/internal/doubly_linked_list.h" 17 | -------------------------------------------------------------------------------- /trpc/server/non_rpc_service_impl.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/server/non_rpc/non_rpc_service_impl.h" 17 | -------------------------------------------------------------------------------- /trpc/stream/http/common/client/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "stream_handler", 7 | srcs = ["stream_handler.cc"], 8 | hdrs = ["stream_handler.h"], 9 | deps = [ 10 | "//trpc/stream/http/common:stream_handler", 11 | ], 12 | ) 13 | 14 | cc_test( 15 | name = "stream_handler_test", 16 | srcs = ["stream_handler_test.cc"], 17 | deps = [ 18 | ":stream_handler", 19 | "@com_google_googletest//:gtest_main", 20 | ], 21 | ) 22 | -------------------------------------------------------------------------------- /trpc/util/thread/bounded_mpmc_queue.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/util/queue/bounded_mpmc_queue.h" 17 | -------------------------------------------------------------------------------- /trpc/util/thread/bounded_mpsc_queue.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/util/queue/bounded_mpsc_queue.h" 17 | -------------------------------------------------------------------------------- /trpc/util/thread/unbounded_spmc_queue.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/util/queue/unbounded_spmc_queue.h" 17 | -------------------------------------------------------------------------------- /trpc/common/async_timer.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | // for compatible 17 | 18 | #include "trpc/future/async_timer.h" 19 | -------------------------------------------------------------------------------- /trpc/server/non_rpc_method_handler.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/server/non_rpc/non_rpc_method_handler.h" 17 | -------------------------------------------------------------------------------- /trpc/server/non_rpc_service_method.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/server/non_rpc/non_rpc_service_method.h" 17 | -------------------------------------------------------------------------------- /trpc/server/stream_rpc_method_handler.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/server/rpc/stream_rpc_method_handler.h" 17 | -------------------------------------------------------------------------------- /trpc/util/algorithm/BUILD: -------------------------------------------------------------------------------- 1 | # Description: trpc-cpp. 2 | 3 | licenses(["notice"]) 4 | 5 | package(default_visibility = ["//visibility:public"]) 6 | 7 | cc_library( 8 | name = "power_of_two", 9 | srcs = ["power_of_two.cc"], 10 | hdrs = ["power_of_two.h"], 11 | deps = [ 12 | ], 13 | ) 14 | 15 | cc_library( 16 | name = "random", 17 | hdrs = ["random.h"], 18 | ) 19 | 20 | cc_library( 21 | name = "hash", 22 | srcs = ["hash.cc"], 23 | hdrs = ["hash.h"], 24 | deps = [ 25 | "//trpc/util/log:logging", 26 | ], 27 | ) 28 | -------------------------------------------------------------------------------- /examples/features/future_forward/client/BUILD: -------------------------------------------------------------------------------- 1 | cc_binary( 2 | name = "client", 3 | srcs = ["client.cc"], 4 | deps = [ 5 | "//examples/features/future_forward/proxy:forward_proto", 6 | "@com_github_gflags_gflags//:gflags", 7 | "@trpc_cpp//trpc/client:make_client_context", 8 | "@trpc_cpp//trpc/common:runtime_manager", 9 | "@trpc_cpp//trpc/client:trpc_client", 10 | "@trpc_cpp//trpc/common:trpc_plugin", 11 | "@trpc_cpp//trpc/future:future_utility", 12 | "@trpc_cpp//trpc/util:time", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /trpc/coroutine/fiber/runtime.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | // for compatible 15 | 16 | #pragma once 17 | 18 | #include "trpc/runtime/fiber_runtime.h" 19 | -------------------------------------------------------------------------------- /trpc/server/rpc_async_method_handler.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/server/async_rpc/async_rpc_method_handler.h" 17 | -------------------------------------------------------------------------------- /docs/zh/faq.md: -------------------------------------------------------------------------------- 1 | # tRPC-Cpp常见问题 2 | 3 | 对日常遇到的问题做了知识沉淀,按各场景整理了一些常见问题以及排查问题的指南,按需取用。 4 | 5 | ## 问题排查指南 6 | 7 | - [性能问题排查排查指南](faq/low_performance.md) 8 | - [客户端超时/失败/长尾问题排查指南](faq/unexpected_cost_time.md) 9 | - [程序crash问题排查指南](faq/program_crash.md) 10 | 11 | ## 常见问题汇总 12 | 13 | - [bazel和cmake常见编译问题](faq/bazel_and_cmake_problem.md) 14 | - [protobuf/proto文件管理常见问题](faq/protobuf_and_proto_import_problem.md) 15 | - [fiber常见问题](faq/fiber_problem.md) 16 | - [future/promise常见问题](faq/future_promise_problem.md) 17 | - [http常见问题](faq/http_promblem.md) 18 | - [日志常见问题](faq/log_problem.md) 19 | -------------------------------------------------------------------------------- /examples/features/http/server/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_binary( 6 | name = "http_server", 7 | srcs = ["http_server.cc"], 8 | linkopts = ["-ldl"], 9 | deps = [ 10 | "@trpc_cpp//trpc/common:trpc_app", 11 | "@trpc_cpp//trpc/server:http_service", 12 | "@trpc_cpp//trpc/util/http:function_handlers", 13 | "@trpc_cpp//trpc/util/http:http_handler", 14 | "@trpc_cpp//trpc/util/http:routes", 15 | "@trpc_cpp//trpc/util/log:logging", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /trpc/common/future/types.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/future/types.h" 17 | 18 | // This file is for compatibility. 19 | -------------------------------------------------------------------------------- /trpc/transport/common/transport_message.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/transport/server/server_transport_message.h" 17 | -------------------------------------------------------------------------------- /trpc/util/latch.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | /// @brief Just for backward compatibility 17 | #include "trpc/util/thread/latch.h" 18 | -------------------------------------------------------------------------------- /examples/features/filter/run_cmake.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j8 && cd - 3 | mkdir -p examples/features/filter/build && cd examples/features/filter/build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j8 && cd - 4 | 5 | # start server and client 6 | ./examples/features/filter/build/demo_server --config=./examples/features/filter/server/trpc_cpp_fiber.yaml & 7 | sleep 1 8 | ./examples/features/filter/build/demo_client --client_config=./examples/features/filter/client/trpc_cpp_separate.yaml 9 | 10 | killall demo_server -------------------------------------------------------------------------------- /examples/features/trpc_attachment/run_cmake.sh: -------------------------------------------------------------------------------- 1 | mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j8 && cd - 2 | mkdir -p examples/features/trpc_attachment/build && cd examples/features/trpc_attachment/build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j8 && cd - 3 | 4 | examples/features/trpc_attachment/build/demo_server --config=./examples/features/trpc_attachment/server/trpc_cpp_fiber.yaml & 5 | sleep 1 6 | examples/features/trpc_attachment/build/client --client_config=./examples/features/trpc_attachment/client/trpc_cpp_fiber.yaml 7 | 8 | killall demo_server 9 | -------------------------------------------------------------------------------- /trpc/common/future/basics.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/future/basics.h" 17 | 18 | // This file is for compatibility. 19 | -------------------------------------------------------------------------------- /trpc/common/future/executor.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/future/executor.h" 17 | 18 | // This file is for compatibility. 19 | -------------------------------------------------------------------------------- /trpc/common/future/future.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/future/future.h" 17 | 18 | // This file is for compatibility. 19 | -------------------------------------------------------------------------------- /trpc/util/async_io/async_io.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | // for compatiblie 17 | #include "trpc/runtime/iomodel/async_io/async_io.h" 18 | -------------------------------------------------------------------------------- /trpc/util/random.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | /// @brief Just for backward compatibility 17 | #include "trpc/util/algorithm/random.h" 18 | -------------------------------------------------------------------------------- /trpc/common/future/exception.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/future/exception.h" 17 | 18 | // This file is for compatibility. 19 | -------------------------------------------------------------------------------- /trpc/filter/filter.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/filter/client_filter_base.h" 17 | #include "trpc/filter/server_filter_base.h" 18 | -------------------------------------------------------------------------------- /trpc/server/stream_rpc_async_method_handler.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/server/async_rpc/async_stream_rpc_method_handler.h" 17 | -------------------------------------------------------------------------------- /trpc/util/string_util.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | /// @brief Just for backward compatibility 17 | #include "trpc/util/string/string_util.h" 18 | -------------------------------------------------------------------------------- /examples/features/request_dispatch/server/BUILD: -------------------------------------------------------------------------------- 1 | cc_binary( 2 | name = "demo_server", 3 | srcs = ["demo_server.cc"], 4 | deps = [ 5 | "//examples/helloworld:helloworld_proto", 6 | "@com_github_fmtlib_fmt//:fmtlib", 7 | "@trpc_cpp//trpc/common:trpc_app", 8 | "@trpc_cpp//trpc/codec/trpc:trpc_protocol", 9 | "@trpc_cpp//trpc/log:trpc_log", 10 | "@trpc_cpp//trpc/runtime/threadmodel/common:worker_thread", 11 | "@trpc_cpp//trpc/util/algorithm:random", 12 | "@trpc_cpp//trpc/util/buffer:zero_copy_stream", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /examples/features/trpc_stream/server/stream.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package trpc.test.helloworld; 4 | 5 | service StreamGreeter { 6 | // Client streaming 7 | rpc ClientStreamSayHello (stream HelloRequest) returns (HelloReply) {} 8 | 9 | // Server streaming 10 | rpc ServerStreamSayHello (HelloRequest) returns (stream HelloReply) {} 11 | 12 | // Bidi streaming 13 | rpc BidiStreamSayHello (stream HelloRequest) returns (stream HelloReply) {} 14 | } 15 | 16 | message HelloRequest { 17 | string msg = 1; 18 | } 19 | 20 | message HelloReply { 21 | string msg = 1; 22 | } 23 | -------------------------------------------------------------------------------- /third_party/com_github_gabime_spdlog/spdlog.BUILD: -------------------------------------------------------------------------------- 1 | package( 2 | default_visibility = ["//visibility:public"], 3 | ) 4 | 5 | cc_library( 6 | name = "spdlog", 7 | srcs = glob(["src/*.cpp"]), 8 | hdrs = glob([ 9 | "include/spdlog/*.h", 10 | "include/spdlog/*/*.h", 11 | "include/spdlog/*/*/*.h", 12 | ]), 13 | defines = [ 14 | "SPDLOG_COMPILED_LIB", 15 | "SPDLOG_FMT_EXTERNAL", 16 | "SPDLOG_DISABLE_DEFAULT_LOGGER", 17 | ], 18 | strip_include_prefix = "include", 19 | deps = ["@com_github_fmtlib_fmt//:fmtlib"], 20 | ) 21 | -------------------------------------------------------------------------------- /trpc/util/http/body_params.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | // Just for the sake of backward compatibility. 17 | #include "trpc/util/http/parameter.h" 18 | -------------------------------------------------------------------------------- /trpc/util/string_helper.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | /// @brief Just for backward compatibility 17 | #include "trpc/util/string/string_helper.h" 18 | -------------------------------------------------------------------------------- /trpc/common/future/function_traits.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/future/function_traits.h" 17 | 18 | // This file is for compatibility. 19 | -------------------------------------------------------------------------------- /trpc/common/future/future_utility.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/future/future_utility.h" 17 | 18 | // This file is for compatibility. 19 | -------------------------------------------------------------------------------- /test/end2end/unary/tvar/conf/tvar_client_merge.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 0.0.0.0 3 | threadmodel: 4 | default: 5 | - instance_name: default_instance 6 | io_handle_type: merge 7 | io_thread_num: 4 8 | 9 | client: 10 | service: 11 | - name: http_client 12 | selector_name: direct 13 | target: 127.0.0.1:31111 14 | protocol: http 15 | network: tcp 16 | conn_type: long 17 | - name: tvar_client 18 | selector_name: direct 19 | target: 127.0.0.1:13001 20 | protocol: trpc 21 | network: tcp 22 | conn_type: long 23 | -------------------------------------------------------------------------------- /trpc/common/future/reactor_executor.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/future/reactor_executor.h" 17 | 18 | // This file is for compatibility. 19 | -------------------------------------------------------------------------------- /examples/features/fiber_forward/client/BUILD: -------------------------------------------------------------------------------- 1 | cc_binary( 2 | name = "client", 3 | srcs = ["client.cc"], 4 | deps = [ 5 | "//examples/features/fiber_forward/proxy:forward_proto", 6 | "@com_github_gflags_gflags//:gflags", 7 | "@trpc_cpp//trpc/client:make_client_context", 8 | "@trpc_cpp//trpc/client:trpc_client", 9 | "@trpc_cpp//trpc/common:runtime_manager", 10 | "@trpc_cpp//trpc/common:trpc_plugin", 11 | "@trpc_cpp//trpc/coroutine:fiber", 12 | "@trpc_cpp//trpc/util:latch", 13 | "@trpc_cpp//trpc/util:time", 14 | ], 15 | ) 16 | -------------------------------------------------------------------------------- /test/end2end/unary/tvar/conf/tvar_server_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 0.0.0.0 3 | coroutine: 4 | enable: true 5 | threadmodel: 6 | fiber: 7 | - instance_name: fiber_instance 8 | concurrency_hint: 8 9 | tvar: 10 | window_size: 10 11 | save_series: true 12 | latency_p1: 80 13 | latency_p2: 90 14 | latency_p3: 95 15 | 16 | server: 17 | app: test 18 | server: test1 19 | admin_ip: 0.0.0.0 20 | admin_port: 31115 21 | service: 22 | - name: tvar_service 23 | protocol: trpc 24 | network: tcp 25 | ip: 0.0.0.0 26 | port: 13005 27 | -------------------------------------------------------------------------------- /test/end2end/unary/tvar/conf/tvar_server_merge.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 0.0.0.0 3 | threadmodel: 4 | default: 5 | - instance_name: default_instance 6 | io_handle_type: merge 7 | io_thread_num: 4 8 | tvar: 9 | window_size: 10 10 | save_series: true 11 | latency_p1: 80 12 | latency_p2: 90 13 | latency_p3: 95 14 | 15 | server: 16 | app: test 17 | server: test1 18 | admin_ip: 0.0.0.0 19 | admin_port: 31111 20 | service: 21 | - name: tvar_service 22 | protocol: trpc 23 | network: tcp 24 | ip: 0.0.0.0 25 | port: 13001 26 | -------------------------------------------------------------------------------- /examples/features/filter/common/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "user_rpc_filter", 5 | hdrs = [ 6 | "user_rpc_filter.h", 7 | ], 8 | deps = [ 9 | "//examples/helloworld:helloworld_proto", 10 | "@trpc_cpp//trpc/filter:rpc_filter", 11 | ], 12 | ) 13 | 14 | cc_library( 15 | name = "invoke_stat_filter", 16 | hdrs = [ 17 | "invoke_stat_filter.h", 18 | ], 19 | deps = [ 20 | "@trpc_cpp//trpc/filter:filter", 21 | "@trpc_cpp//trpc/common/logging:trpc_logging", 22 | ], 23 | ) 24 | -------------------------------------------------------------------------------- /test/end2end/unary/tvar/conf/tvar_client_merge_noseries.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 0.0.0.0 3 | threadmodel: 4 | default: 5 | - instance_name: default_instance 6 | io_handle_type: merge 7 | io_thread_num: 4 8 | 9 | client: 10 | service: 11 | - name: http_client 12 | selector_name: direct 13 | target: 127.0.0.1:31112 14 | protocol: http 15 | network: tcp 16 | conn_type: long 17 | - name: tvar_client 18 | selector_name: direct 19 | target: 127.0.0.1:13002 20 | protocol: trpc 21 | network: tcp 22 | conn_type: long 23 | -------------------------------------------------------------------------------- /trpc/server/rpc_service_impl.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/server/rpc/rpc_service_impl.h" 17 | #include "trpc/server/async_rpc/async_rpc_service_impl.h" 18 | -------------------------------------------------------------------------------- /examples/features/trpc_flatbuffers/run.sh: -------------------------------------------------------------------------------- 1 | bazel build //examples/features/trpc_flatbuffers/... 2 | 3 | echo "begin" 4 | ./bazel-bin/examples/features/trpc_flatbuffers/server/demoserver --config=./examples/features/trpc_flatbuffers/server/trpc_cpp_fiber.yaml & 5 | sleep 1 6 | ./bazel-bin/examples/features/trpc_flatbuffers/proxy/forwardserver --config=./examples/features/trpc_flatbuffers/proxy/trpc_cpp_fiber.yaml & 7 | sleep 1 8 | ./bazel-bin/examples/features/trpc_flatbuffers/client/client --client_config=./examples/features/trpc_flatbuffers/client/trpc_cpp_fiber.yaml 9 | killall demoserver 10 | killall forwardserver 11 | -------------------------------------------------------------------------------- /test/end2end/unary/http/http_rpc.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package trpc.testing.httpsvr; 4 | 5 | import "trpc/proto/trpc_options.proto"; 6 | 7 | service HttpRpcService { 8 | rpc TestPb (TestRequest) returns (TestReply) { 9 | option (trpc.alias) = "/test-pb"; 10 | } 11 | 12 | rpc TestPbEmptyReq (TestRequest) returns (TestReply) {} 13 | 14 | rpc TestPbEmptyRsp (TestRequest) returns (TestReply) {} 15 | 16 | rpc TestPbRetErr (TestRequest) returns (TestReply) {} 17 | } 18 | 19 | message TestRequest { 20 | string msg = 1; 21 | } 22 | 23 | message TestReply { 24 | string msg = 1; 25 | } 26 | -------------------------------------------------------------------------------- /test/end2end/unary/tvar/conf/tvar_server_fiber_noseries.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 0.0.0.0 3 | coroutine: 4 | enable: true 5 | threadmodel: 6 | fiber: 7 | - instance_name: fiber_instance 8 | concurrency_hint: 8 9 | tvar: 10 | window_size: 10 11 | save_series: false 12 | latency_p1: 80 13 | latency_p2: 90 14 | latency_p3: 95 15 | 16 | server: 17 | app: test 18 | server: test1 19 | admin_ip: 0.0.0.0 20 | admin_port: 31116 21 | service: 22 | - name: tvar_service 23 | protocol: trpc 24 | network: tcp 25 | ip: 0.0.0.0 26 | port: 13006 27 | -------------------------------------------------------------------------------- /test/end2end/unary/tvar/conf/tvar_server_merge_noseries.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 0.0.0.0 3 | threadmodel: 4 | default: 5 | - instance_name: default_instance 6 | io_handle_type: merge 7 | io_thread_num: 4 8 | tvar: 9 | window_size: 10 10 | save_series: false 11 | latency_p1: 80 12 | latency_p2: 90 13 | latency_p3: 95 14 | 15 | server: 16 | app: test 17 | server: test1 18 | admin_ip: 0.0.0.0 19 | admin_port: 31112 20 | service: 21 | - name: tvar_service 22 | protocol: trpc 23 | network: tcp 24 | ip: 0.0.0.0 25 | port: 13002 26 | -------------------------------------------------------------------------------- /examples/features/thirdparty_protocol/run_cmake.sh: -------------------------------------------------------------------------------- 1 | mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j8 && cd - 2 | mkdir -p examples/features/thirdparty_protocol/build && cd examples/features/thirdparty_protocol/build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j8 && cd - 3 | 4 | echo "begin" 5 | examples/features/thirdparty_protocol/build/demo_server --config=./examples/features/thirdparty_protocol/server/trpc_cpp_fiber.yaml & 6 | sleep 1 7 | examples/features/thirdparty_protocol/build/client --client_config=./examples/features/thirdparty_protocol/client/trpc_cpp_fiber.yaml 8 | killall demo_server 9 | -------------------------------------------------------------------------------- /test/end2end/unary/http/conf/http_rpc_test/http_client_merge.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 127.0.0.1 3 | threadmodel: 4 | default: 5 | - instance_name: default_instance 6 | io_handle_type: merge 7 | io_thread_num: 8 8 | 9 | client: 10 | service: 11 | - name: http_client 12 | selector_name: direct 13 | target: 127.0.0.1:16792 14 | protocol: http 15 | network: tcp 16 | conn_type: long 17 | - name: http_rpc_client 18 | selector_name: direct 19 | target: 127.0.0.1:16792 20 | protocol: http 21 | network: tcp 22 | conn_type: long 23 | -------------------------------------------------------------------------------- /trpc/stream/http/common/server/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "stream_handler", 5 | srcs = ["stream_handler.cc"], 6 | hdrs = ["stream_handler.h"], 7 | deps = [ 8 | "//trpc/codec:server_codec_factory", 9 | "//trpc/stream/http/common:stream_handler", 10 | ], 11 | ) 12 | 13 | cc_test( 14 | name = "stream_handler_test", 15 | srcs = ["stream_handler_test.cc"], 16 | deps = [ 17 | ":stream_handler", 18 | "//trpc/codec:codec_manager", 19 | "@com_google_googletest//:gtest_main", 20 | ], 21 | ) 22 | -------------------------------------------------------------------------------- /examples/features/http_async_upload_download/server/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_binary( 6 | name = "http_async_upload_download_server", 7 | srcs = ["http_server.cc"], 8 | linkopts = ["-ldl"], 9 | deps = [ 10 | "@trpc_cpp//trpc/common:trpc_app", 11 | "@trpc_cpp//trpc/future:future_utility", 12 | "@trpc_cpp//trpc/server:http_service", 13 | "@trpc_cpp//trpc/server/http:http_async_stream_service", 14 | "@trpc_cpp//trpc/util:random", 15 | "@trpc_cpp//trpc/util/log:logging", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /examples/features/thirdparty_protocol/client/BUILD: -------------------------------------------------------------------------------- 1 | cc_binary( 2 | name = "client", 3 | srcs = ["client.cc"], 4 | deps = [ 5 | "//examples/features/thirdparty_protocol/common:demo_client_codec", 6 | "//examples/features/thirdparty_protocol/common:demo_protocol", 7 | "@com_github_gflags_gflags//:gflags", 8 | "@trpc_cpp//trpc/client:make_client_context", 9 | "@trpc_cpp//trpc/client:non_rpc_service_proxy", 10 | "@trpc_cpp//trpc/common:runtime_manager", 11 | "@trpc_cpp//trpc/client:trpc_client", 12 | "@trpc_cpp//trpc/common:trpc_plugin", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /test/end2end/unary/future/conf/future_server_separate.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 0.0.0.0 3 | threadmodel: 4 | # Just cooperate with client_separate, server no need to run in separate. 5 | default: 6 | - instance_name: default_instance 7 | io_handle_type: merge 8 | io_thread_num: 4 9 | 10 | server: 11 | app: test 12 | server: test1 13 | service: 14 | - name: tcp_service 15 | protocol: trpc 16 | network: tcp 17 | ip: 0.0.0.0 18 | port: 14005 19 | - name: udp_service 20 | protocol: trpc 21 | network: udp 22 | ip: 0.0.0.0 23 | port: 14007 24 | -------------------------------------------------------------------------------- /examples/features/tvar/client/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_binary( 6 | name = "client", 7 | srcs = ["client.cc"], 8 | linkopts = ["-ldl"], 9 | deps = [ 10 | "//examples/features/tvar/server:tvar_proto", 11 | "@trpc_cpp//trpc/client:make_client_context", 12 | "@trpc_cpp//trpc/client:trpc_client", 13 | "@trpc_cpp//trpc/common:runtime_manager", 14 | "@trpc_cpp//trpc/common:trpc_plugin", 15 | "@trpc_cpp//trpc/common/config:trpc_config", 16 | "@trpc_cpp//trpc/util/log:logging", 17 | ], 18 | ) 19 | -------------------------------------------------------------------------------- /test/end2end/unary/trpc/trpc_server.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023, Tencent Inc. 2 | // All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "test/end2end/common/test_signaller.h" 7 | #include "trpc/common/trpc_app.h" 8 | 9 | namespace trpc::testing { 10 | 11 | /// @brief Server for trpc unary test 12 | class TrpcTestServer : public ::trpc::TrpcApp { 13 | public: 14 | explicit TrpcTestServer(TestSignaller* test_signal) : test_signal_(test_signal) {} 15 | int Initialize() override; 16 | void Destroy() override; 17 | 18 | private: 19 | TestSignaller* test_signal_{nullptr}; 20 | }; 21 | 22 | } // namespace trpc::testing 23 | -------------------------------------------------------------------------------- /examples/features/filter/client/trpc_cpp_separate.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | default: 4 | - instance_name: default_instance 5 | io_handle_type: separate 6 | io_thread_num: 2 7 | handle_thread_num: 6 8 | 9 | client: 10 | service: 11 | - name: trpc.test.helloworld.Greeter 12 | target: 127.0.0.1:10001 13 | protocol: trpc 14 | timeout: 1000 15 | network: tcp 16 | selector_name: direct 17 | filter: # service-level filter 18 | - user_pb_rpc_client_filter 19 | filter: # global filter 20 | - client_invoke_stat 21 | -------------------------------------------------------------------------------- /examples/features/request_dispatch/server/trpc_cpp_separate.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | default: 4 | - instance_name: default_instance 5 | io_handle_type: separate 6 | io_thread_num: 2 7 | handle_thread_num: 8 8 | 9 | server: 10 | app: test 11 | server: helloworld 12 | service: 13 | - name: trpc.test.helloworld.Greeter 14 | protocol: trpc 15 | network: tcp 16 | ip: 0.0.0.0 17 | port: 12353 18 | 19 | plugins: 20 | log: 21 | default: 22 | - name: default 23 | sinks: 24 | local_file: 25 | filename: request_dispatch_in_separate.log -------------------------------------------------------------------------------- /trpc/client/grpc/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_test( 6 | name = "grpc_fiber_test", 7 | srcs = ["grpc_fiber_test.cc"], 8 | data = [ 9 | "//trpc/client/grpc/testing:grpc_fiber.yaml", 10 | ], 11 | deps = [ 12 | "//trpc/client:trpc_client", 13 | "//trpc/client/grpc/testing:grpc_client_call_testing", 14 | "//trpc/server/testing:fiber_server_testing", 15 | "//trpc/server/testing:greeter_service_testing", 16 | "@com_google_googletest//:gtest", 17 | "@com_google_googletest//:gtest_main", 18 | ], 19 | ) -------------------------------------------------------------------------------- /trpc/codec/non_rpc_protocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/codec/protocol.h" 17 | 18 | namespace trpc { 19 | 20 | using NonRpcProtocol = Protocol; 21 | 22 | } // namespace trpc 23 | -------------------------------------------------------------------------------- /trpc/compressor/gzip/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "gzip_compressor", 7 | hdrs = ["gzip_compressor.h"], 8 | deps = [ 9 | "//trpc/compressor", 10 | "//trpc/compressor:compressor_type", 11 | "//trpc/compressor/common:zlib_util", 12 | ], 13 | ) 14 | 15 | cc_test( 16 | name = "gzip_compressor_test", 17 | srcs = ["gzip_compressor_test.cc"], 18 | deps = [ 19 | ":gzip_compressor", 20 | "@com_google_googletest//:gtest", 21 | "@com_google_googletest//:gtest_main", 22 | ], 23 | ) 24 | -------------------------------------------------------------------------------- /trpc/util/hazptr/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hazptr", 7 | srcs = [ 8 | "entry_cache.cc", 9 | "hazptr_domain.cc", 10 | "hazptr_object.cc", 11 | ], 12 | hdrs = [ 13 | "entry.h", 14 | "entry_cache.h", 15 | "hazptr.h", 16 | "hazptr_domain.h", 17 | "hazptr_object.h", 18 | ], 19 | deps = [ 20 | "//trpc/util/internal:never_destroyed", 21 | "//trpc/util/internal:time_keeper", 22 | "//trpc/util/thread/internal:memory_barrier", 23 | ], 24 | ) 25 | -------------------------------------------------------------------------------- /test/end2end/unary/trpc/trpc_route_server.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023, Tencent Inc. 2 | // All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "test/end2end/common/test_signaller.h" 7 | #include "trpc/common/trpc_app.h" 8 | 9 | namespace trpc::testing { 10 | 11 | /// @brief RouteServer for trpc unary test 12 | class RouteTestServer : public ::trpc::TrpcApp { 13 | public: 14 | explicit RouteTestServer(TestSignaller* test_signal) : test_signal_(test_signal) {} 15 | int Initialize() override; 16 | void Destroy() override; 17 | 18 | private: 19 | TestSignaller* test_signal_{nullptr}; 20 | }; 21 | 22 | } // namespace trpc::testing 23 | -------------------------------------------------------------------------------- /test/end2end/unary/tvar/conf/tvar_server_separate.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 0.0.0.0 3 | threadmodel: 4 | default: 5 | - instance_name: default_instance 6 | io_handle_type: separate 7 | io_thread_num: 4 8 | handle_thread_num: 4 9 | tvar: 10 | window_size: 10 11 | save_series: true 12 | latency_p1: 80 13 | latency_p2: 90 14 | latency_p3: 95 15 | 16 | server: 17 | app: test 18 | server: test1 19 | admin_ip: 0.0.0.0 20 | admin_port: 31113 21 | service: 22 | - name: tvar_service 23 | protocol: trpc 24 | network: tcp 25 | ip: 0.0.0.0 26 | port: 13003 27 | -------------------------------------------------------------------------------- /examples/unittest/client/trpc_cpp.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | default: 4 | - instance_name: default_instance 5 | io_handle_type: separate 6 | io_thread_num: 2 7 | handle_thread_num: 6 8 | 9 | client: 10 | service: 11 | - name: trpc.test.unittest.Greeter 12 | protocol: trpc 13 | network: tcp 14 | target: 0.0.0.0:12345 15 | selector_name: direct 16 | 17 | plugins: 18 | log: 19 | default: 20 | - name: default 21 | min_level: 1 # 0-trace, 1-debug, 2-info, 3-warn, 4-error, 5-critical 22 | sinks: 23 | local_file: 24 | filename: client.log -------------------------------------------------------------------------------- /trpc/stream/testing/stream.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package trpc.test.helloworld; 4 | 5 | service Greeter { 6 | // Unary 7 | rpc SayHello (HelloRequest) returns (HelloReply) {} 8 | 9 | // Client streaming 10 | rpc ClientStreamSayHello (stream HelloRequest) returns (HelloReply) {} 11 | 12 | // Server streaming 13 | rpc ServerStreamSayHello (HelloRequest) returns (stream HelloReply) {} 14 | 15 | // Bidi streaming 16 | rpc BidiStreamSayHello (stream HelloRequest) returns (stream HelloReply) {} 17 | } 18 | 19 | message HelloRequest { 20 | string msg = 1; 21 | } 22 | 23 | message HelloReply { 24 | string msg = 1; 25 | } 26 | -------------------------------------------------------------------------------- /trpc/tvar/BUILD: -------------------------------------------------------------------------------- 1 | # Description: trpc-cpp. 2 | 3 | licenses(["notice"]) 4 | 5 | package(default_visibility = ["//visibility:public"]) 6 | 7 | cc_library( 8 | name = "tvar", 9 | hdrs = ["tvar.h"], 10 | visibility = [ 11 | "//visibility:public", 12 | ], 13 | deps = [ 14 | "//trpc/tvar/basic_ops:passive_status", 15 | "//trpc/tvar/basic_ops:recorder", 16 | "//trpc/tvar/basic_ops:reducer", 17 | "//trpc/tvar/basic_ops:status", 18 | "//trpc/tvar/common:tvar_group", 19 | "//trpc/tvar/compound_ops:latency_recorder", 20 | "//trpc/tvar/compound_ops:window", 21 | ], 22 | ) 23 | -------------------------------------------------------------------------------- /trpc/util/http/http_header.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/util/http/header.h" 17 | 18 | namespace trpc::http { 19 | 20 | using HttpHeader = HeaderPairs; 21 | 22 | } // namespace trpc::http 23 | -------------------------------------------------------------------------------- /test/end2end/unary/tvar/conf/tvar_server_separate_noseries.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 0.0.0.0 3 | threadmodel: 4 | default: 5 | - instance_name: default_instance 6 | io_handle_type: separate 7 | io_thread_num: 4 8 | handle_thread_num: 4 9 | tvar: 10 | window_size: 10 11 | save_series: false 12 | latency_p1: 80 13 | latency_p2: 90 14 | latency_p3: 95 15 | 16 | server: 17 | app: test 18 | server: test1 19 | admin_ip: 0.0.0.0 20 | admin_port: 31114 21 | service: 22 | - name: tvar_service 23 | protocol: trpc 24 | network: tcp 25 | ip: 0.0.0.0 26 | port: 13004 27 | -------------------------------------------------------------------------------- /trpc/proto/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package( 4 | default_visibility = [ 5 | "//trpc:__subpackages__", 6 | "//test:__subpackages__", 7 | ] 8 | ) 9 | 10 | proto_library( 11 | name = "trpc_proto", 12 | srcs = [ 13 | "trpc.proto", 14 | ], 15 | ) 16 | 17 | proto_library( 18 | name = "trpc_options_proto", 19 | srcs = [ 20 | "trpc_options.proto", 21 | ], 22 | deps = [ 23 | "@com_google_protobuf//:descriptor_proto", 24 | ], 25 | ) 26 | 27 | cc_proto_library( 28 | name = "cc_trpc_options_proto", 29 | deps = [ 30 | ":trpc_options_proto", 31 | ], 32 | ) 33 | -------------------------------------------------------------------------------- /examples/features/redis/client/future/BUILD: -------------------------------------------------------------------------------- 1 | cc_binary( 2 | name = "future_client", 3 | srcs = ["future_client.cc"], 4 | linkopts = ["-ldl"], 5 | deps = [ 6 | "@com_github_gflags_gflags//:gflags", 7 | "@trpc_cpp//trpc/client:client_context", 8 | "@trpc_cpp//trpc/client:make_client_context", 9 | "@trpc_cpp//trpc/client:trpc_client", 10 | "@trpc_cpp//trpc/client/redis:redis_service_proxy", 11 | "@trpc_cpp//trpc/client/redis:reply", 12 | "@trpc_cpp//trpc/common:runtime_manager", 13 | "@trpc_cpp//trpc/common:trpc_plugin", 14 | "@trpc_cpp//trpc/future:future_utility", 15 | ], 16 | ) -------------------------------------------------------------------------------- /test/end2end/stream/trpc/conf/sync_test/sync_stream_server.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | fiber: 4 | - instance_name: fiber_instance 5 | concurrency_hint: 4 6 | 7 | server: 8 | app: testing 9 | server: stream_test 10 | service: 11 | - name: trpc.testing.stream_test.SyncStreamService 12 | protocol: trpc 13 | port: 14216 14 | - name: trpc.testing.stream_test.SyncStreamServiceConnIdle 15 | protocol: trpc 16 | port: 14218 17 | idle_time: 2000 18 | - name: trpc.testing.stream_test.SyncStreamServiceNoFlowControl 19 | protocol: trpc 20 | port: 14220 21 | stream_max_window_size: 0 22 | -------------------------------------------------------------------------------- /test/end2end/unary/http/conf/http_rpc_test/http_client_separate.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 127.0.0.1 3 | threadmodel: 4 | default: 5 | - instance_name: default_instance 6 | io_handle_type: separate 7 | io_thread_num: 2 8 | handle_thread_num: 4 9 | 10 | client: 11 | service: 12 | - name: http_client 13 | selector_name: direct 14 | target: 127.0.0.1:16793 15 | protocol: http 16 | network: tcp 17 | conn_type: long 18 | - name: http_rpc_client 19 | selector_name: direct 20 | target: 127.0.0.1:16793 21 | protocol: http 22 | network: tcp 23 | conn_type: long 24 | -------------------------------------------------------------------------------- /trpc/client/trpc_service_proxy.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/client/rpc_service_proxy.h" 17 | 18 | namespace trpc { 19 | 20 | using TrpcServiceProxy = RpcServiceProxy; 21 | 22 | } // namespace trpc 23 | -------------------------------------------------------------------------------- /test/end2end/stream/trpc/conf/async_test/sync_stream_server.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | fiber: 4 | - instance_name: fiber_instance 5 | concurrency_hint: 4 6 | 7 | server: 8 | app: testing 9 | server: stream_test 10 | service: 11 | - name: trpc.testing.stream_test.SyncStreamService 12 | protocol: trpc 13 | port: 13216 14 | - name: trpc.testing.stream_test.SyncStreamServiceConnIdle 15 | protocol: trpc 16 | port: 13218 17 | idle_time: 2000 18 | - name: trpc.testing.stream_test.SyncStreamServiceNoFlowControl 19 | protocol: trpc 20 | port: 13220 21 | stream_max_window_size: 0 22 | -------------------------------------------------------------------------------- /test/end2end/stream/trpc/async_stream_server.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023, Tencent Inc. 2 | // All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "test/end2end/common/test_signaller.h" 7 | #include "trpc/common/trpc_app.h" 8 | 9 | namespace trpc::testing { 10 | 11 | /// @brief Streaming server (using asynchronous stream interface). 12 | class AsyncStreamServer : public ::trpc::TrpcApp { 13 | public: 14 | explicit AsyncStreamServer(TestSignaller* test_signal) : test_signal_(test_signal) {} 15 | int Initialize() override; 16 | void Destroy() override; 17 | 18 | private: 19 | TestSignaller* test_signal_{nullptr}; 20 | }; 21 | 22 | } // namespace trpc::testing 23 | -------------------------------------------------------------------------------- /test/end2end/stream/trpc/sync_stream_server.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023, Tencent Inc. 2 | // All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "test/end2end/common/test_signaller.h" 7 | #include "trpc/common/trpc_app.h" 8 | 9 | namespace trpc::testing { 10 | 11 | /// @brief Streaming server (using synchronous stream interface). 12 | class SyncStreamServer : public ::trpc::TrpcApp { 13 | public: 14 | explicit SyncStreamServer(TestSignaller* test_signal) : test_signal_(test_signal) {} 15 | int Initialize() override; 16 | void Destroy() override; 17 | 18 | private: 19 | TestSignaller* test_signal_{nullptr}; 20 | }; 21 | 22 | } // namespace trpc::testing 23 | -------------------------------------------------------------------------------- /test/end2end/unary/tvar/conf/tvar_client_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 0.0.0.0 3 | threadmodel: 4 | # Just cooperate with server_fiber, client no need to run in fiber. 5 | default: 6 | - instance_name: default_instance 7 | io_handle_type: merge 8 | io_thread_num: 4 9 | 10 | client: 11 | service: 12 | - name: http_client 13 | selector_name: direct 14 | target: 127.0.0.1:31115 15 | protocol: http 16 | network: tcp 17 | conn_type: long 18 | - name: tvar_client 19 | selector_name: direct 20 | target: 127.0.0.1:13005 21 | protocol: trpc 22 | network: tcp 23 | conn_type: long 24 | -------------------------------------------------------------------------------- /examples/unittest/server/async/trpc_cpp.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | default: 4 | - instance_name: default_instance 5 | io_handle_type: separate 6 | io_thread_num: 2 7 | handle_thread_num: 6 8 | 9 | server: 10 | app: test 11 | server: unittest 12 | service: 13 | - name: trpc.test.unittest.Greeter 14 | protocol: trpc 15 | network: tcp 16 | ip: 0.0.0.0 17 | port: 12345 18 | 19 | plugins: 20 | log: 21 | default: 22 | - name: default 23 | min_level: 1 # 0-trace, 1-debug, 2-info, 3-warn, 4-error, 5-critical 24 | sinks: 25 | local_file: 26 | filename: server.log 27 | -------------------------------------------------------------------------------- /examples/features/rpcz/client/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_binary( 6 | name = "client", 7 | srcs = ["client.cc"], 8 | linkopts = ["-ldl"], 9 | deps = [ 10 | "//examples/features/rpcz/proxy:rpcz_proto", 11 | "@trpc_cpp//trpc/client:make_client_context", 12 | "@trpc_cpp//trpc/client:trpc_client", 13 | "@trpc_cpp//trpc/common:runtime_manager", 14 | "@trpc_cpp//trpc/common:trpc_plugin", 15 | "@trpc_cpp//trpc/common/config:trpc_config", 16 | "@trpc_cpp//trpc/future:future_utility", 17 | "@trpc_cpp//trpc/util/log:logging", 18 | ], 19 | ) 20 | -------------------------------------------------------------------------------- /test/end2end/unary/rpcz/conf/rpcz_client_merge.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 0.0.0.0 3 | threadmodel: 4 | default: 5 | - instance_name: default_instance 6 | io_handle_type: merge 7 | io_thread_num: 4 8 | 9 | client: 10 | service: 11 | - name: rpcz_client 12 | selector_name: direct 13 | target: 127.0.0.1:15001 14 | protocol: trpc 15 | network: tcp 16 | conn_type: long 17 | is_conn_complex: true 18 | timeout: 1000 19 | - name: http_client 20 | selector_name: direct 21 | target: 127.0.0.1:32111 22 | protocol: http 23 | network: tcp 24 | conn_type: long 25 | timeout: 1000 26 | -------------------------------------------------------------------------------- /test/end2end/unary/tvar/conf/tvar_client_fiber_noseries.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 0.0.0.0 3 | threadmodel: 4 | # Just cooperate with server_fiber, client no need to run in fiber. 5 | default: 6 | - instance_name: default_instance 7 | io_handle_type: merge 8 | io_thread_num: 4 9 | 10 | client: 11 | service: 12 | - name: http_client 13 | selector_name: direct 14 | target: 127.0.0.1:31116 15 | protocol: http 16 | network: tcp 17 | conn_type: long 18 | - name: tvar_client 19 | selector_name: direct 20 | target: 127.0.0.1:13006 21 | protocol: trpc 22 | network: tcp 23 | conn_type: long 24 | -------------------------------------------------------------------------------- /test/end2end/unary/tvar/conf/tvar_client_separate.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 0.0.0.0 3 | threadmodel: 4 | # Just cooperate with server_separate, client no need to run in separate. 5 | default: 6 | - instance_name: default_instance 7 | io_handle_type: merge 8 | io_thread_num: 4 9 | 10 | client: 11 | service: 12 | - name: http_client 13 | selector_name: direct 14 | target: 127.0.0.1:31113 15 | protocol: http 16 | network: tcp 17 | conn_type: long 18 | - name: tvar_client 19 | selector_name: direct 20 | target: 127.0.0.1:13003 21 | protocol: trpc 22 | network: tcp 23 | conn_type: long 24 | -------------------------------------------------------------------------------- /trpc/filter/testing/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "client_filter_testing", 7 | hdrs = ["client_filter_testing.h"], 8 | deps = [ 9 | "//trpc/filter:client_filter_base", 10 | "@com_google_googletest//:gtest", 11 | "@com_google_googletest//:gtest_main", 12 | ], 13 | ) 14 | 15 | cc_library( 16 | name = "server_filter_testing", 17 | hdrs = ["server_filter_testing.h"], 18 | deps = [ 19 | "//trpc/filter:server_filter_base", 20 | "@com_google_googletest//:gtest", 21 | "@com_google_googletest//:gtest_main", 22 | ], 23 | ) 24 | -------------------------------------------------------------------------------- /examples/features/prometheus/client/trpc_cpp_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | fiber: 4 | - instance_name: fiber_instance 5 | concurrency_hint: 4 6 | scheduling_group_size: 4 7 | reactor_num_per_scheduling_group: 1 8 | 9 | client: 10 | filter: 11 | - prometheus 12 | 13 | plugins: 14 | metrics: 15 | prometheus: 16 | histogram_module_cfg: 17 | - 1 18 | - 5 19 | - 10 20 | const_labels: 21 | const_key1: const_value1 22 | const_key2: const_value2 23 | log: 24 | default: 25 | - name: default 26 | sinks: 27 | local_file: 28 | filename: client.log 29 | -------------------------------------------------------------------------------- /trpc/common/trpc_version.cc: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #include "trpc/common/trpc_version.h" 15 | 16 | const char TRPC_Cpp_Version_String[] = TRPC_CPP_VERSION_STRING; 17 | 18 | extern "C" { 19 | const char* TRPC_Cpp_Version() { return TRPC_Cpp_Version_String; } 20 | } 21 | -------------------------------------------------------------------------------- /trpc/filter/trpc_filter.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | namespace trpc::filter { 17 | 18 | /// @brief Initialize filter. 19 | /// @note This function is called by framework when initialized. 20 | bool Init(); 21 | 22 | } // namespace trpc::filter 23 | -------------------------------------------------------------------------------- /examples/features/trpc_compressor/run_cmake.sh: -------------------------------------------------------------------------------- 1 | mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j8 && cd - 2 | mkdir -p examples/helloworld/build && cd examples/helloworld/build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j8 && cd - 3 | mkdir -p examples/features/trpc_compressor/build && cd examples/features/trpc_compressor/build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j8 && cd - 4 | 5 | examples/helloworld/build/helloworld_svr --config=./examples/helloworld/conf/trpc_cpp_fiber.yaml & 6 | sleep 1 7 | examples/features/trpc_compressor/build/client --client_config=./examples/features/trpc_compressor/client/trpc_cpp_fiber.yaml 8 | 9 | killall helloworld_svr 10 | -------------------------------------------------------------------------------- /test/end2end/unary/tvar/conf/tvar_client_separate_noseries.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 0.0.0.0 3 | threadmodel: 4 | # Just cooperate with server_separate, client no need to run in separate. 5 | default: 6 | - instance_name: default_instance 7 | io_handle_type: merge 8 | io_thread_num: 4 9 | 10 | client: 11 | service: 12 | - name: http_client 13 | selector_name: direct 14 | target: 127.0.0.1:31114 15 | protocol: http 16 | network: tcp 17 | conn_type: long 18 | - name: tvar_client 19 | selector_name: direct 20 | target: 127.0.0.1:13004 21 | protocol: trpc 22 | network: tcp 23 | conn_type: long 24 | -------------------------------------------------------------------------------- /trpc/config/testing/test_load.yaml: -------------------------------------------------------------------------------- 1 | # Simple values 2 | integer: -42 3 | unsigned_integer: 123 4 | float: 3.14 5 | double: 1.23456789 6 | boolean: true 7 | string: "Hello, World!" 8 | 9 | # Complex structures 10 | 11 | # Map 12 | map: 13 | key1: "value1" 14 | key2: 123 15 | nested_map: 16 | nested_key1: "nested_value1" 17 | nested_key2: false 18 | 19 | # List 20 | list: 21 | - "item1" 22 | - 456 23 | - 7.89 24 | - true 25 | 26 | # Nested list 27 | nested_list: 28 | - - "nested_item1" 29 | - 111 30 | - - "nested_item2" 31 | - 222 32 | 33 | # Mixed map and list 34 | mixed: 35 | key1: 36 | - "item1" 37 | - 333 38 | key2: 39 | - "item2" 40 | - 444 -------------------------------------------------------------------------------- /trpc/proto/trpc_options.proto: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making tRPC available. 2 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved. 3 | // If you have downloaded a copy of the tRPC source code from Tencent, 4 | // please note that tRPC source code is licensed under the Apache 2.0 License, 5 | // A copy of the Apache 2.0 License is included in this file. 6 | 7 | syntax = "proto3"; 8 | 9 | import "google/protobuf/descriptor.proto"; 10 | 11 | package trpc; 12 | 13 | extend google.protobuf.MethodOptions { 14 | string alias = 50001; 15 | } 16 | 17 | extend google.protobuf.FieldOptions { 18 | string go_tag = 50050; 19 | } 20 | -------------------------------------------------------------------------------- /trpc/serialization/noop/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "noop_serialization", 7 | srcs = ["noop_serialization.cc"], 8 | hdrs = ["noop_serialization.h"], 9 | deps = [ 10 | "//trpc/serialization", 11 | "//trpc/util/buffer:zero_copy_stream", 12 | "//trpc/util/log:logging", 13 | ], 14 | ) 15 | 16 | cc_test( 17 | name = "noop_serialization_test", 18 | srcs = ["noop_serialization_test.cc"], 19 | deps = [ 20 | ":noop_serialization", 21 | "@com_google_googletest//:gtest", 22 | "@com_google_googletest//:gtest_main", 23 | ], 24 | ) 25 | -------------------------------------------------------------------------------- /trpc/util/log/default/sinks/stdout/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "stdout_sink", 7 | hdrs = ["stdout_sink.h"], 8 | deps = [ 9 | "//trpc/common/config:default_log_conf", 10 | "//trpc/common/config:stdout_sink_conf", 11 | "//trpc/util:ref_ptr", 12 | "@com_github_gabime_spdlog//:spdlog", 13 | ], 14 | ) 15 | 16 | cc_test( 17 | name = "stdout_sink_test", 18 | srcs = ["stdout_sink_test.cc"], 19 | deps = [ 20 | ":stdout_sink", 21 | "@com_google_googletest//:gtest", 22 | "@com_google_googletest//:gtest_main", 23 | ], 24 | ) 25 | -------------------------------------------------------------------------------- /examples/features/redis/client/fiber/BUILD: -------------------------------------------------------------------------------- 1 | cc_binary( 2 | name = "fiber_client", 3 | srcs = ["fiber_client.cc"], 4 | linkopts = ["-ldl"], 5 | deps = [ 6 | "@com_github_gflags_gflags//:gflags", 7 | "@trpc_cpp//trpc/client:client_context", 8 | "@trpc_cpp//trpc/client:make_client_context", 9 | "@trpc_cpp//trpc/client:trpc_client", 10 | "@trpc_cpp//trpc/client/redis:redis_service_proxy", 11 | "@trpc_cpp//trpc/client/redis:reply", 12 | "@trpc_cpp//trpc/common:runtime_manager", 13 | "@trpc_cpp//trpc/common:trpc_plugin", 14 | "@trpc_cpp//trpc/coroutine:fiber", 15 | "@trpc_cpp//trpc/util:latch", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /trpc/util/hazptr/hazptr_object.cc: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved. 4 | // Flare is licensed under the BSD 3-Clause License. 5 | // The source codes in this file based on 6 | // https://github.com/Tencent/flare/blob/master/flare/base/hazptr/hazptr_object.cc. 7 | // This source file may have been modified by THL A29 Limited, and licensed under the BSD 3-Clause License. 8 | // 9 | // 10 | 11 | #include "trpc/util/hazptr/hazptr_object.h" 12 | 13 | #include "trpc/util/hazptr/hazptr_domain.h" 14 | 15 | namespace trpc::hazptr { 16 | 17 | void Object::PushRetired(HazptrDomain* domain) { domain->Retire(this); } 18 | 19 | } // namespace trpc::hazptr 20 | -------------------------------------------------------------------------------- /examples/helloworld/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | bazel build //examples/helloworld/... 4 | 5 | echo "testing server at fiber runtime" 6 | ./bazel-bin/examples/helloworld/helloworld_svr --config=./examples/helloworld/conf/trpc_cpp_fiber.yaml & 7 | sleep 1 8 | ./bazel-bin/examples/helloworld/test/fiber_client --client_config=./examples/helloworld/test/conf/trpc_cpp_fiber.yaml 9 | killall helloworld_svr 10 | echo "testing server at thread runtime" 11 | ./bazel-bin/examples/helloworld/helloworld_svr --config=./examples/helloworld/conf/trpc_cpp.yaml & 12 | sleep 1 13 | ./bazel-bin/examples/helloworld/test/future_client --client_config=./examples/helloworld/test/conf/trpc_cpp_future.yaml 14 | killall helloworld_svr 15 | -------------------------------------------------------------------------------- /trpc/coroutine/fiber_mutex.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 4 | // Flare is licensed under the BSD 3-Clause License. 5 | // The source codes in this file based on 6 | // https://github.com/Tencent/flare/blob/master/flare/fiber/mutex.h. 7 | // This source file may have been modified by THL A29 Limited, and licensed under the BSD 3-Clause License. 8 | // 9 | // 10 | 11 | #pragma once 12 | 13 | #include "trpc/runtime/threadmodel/fiber/detail/waitable.h" 14 | 15 | namespace trpc { 16 | 17 | /// @brief Adaptive mutex primitive for both fiber and pthread context. 18 | using FiberMutex = ::trpc::fiber::detail::Mutex; 19 | 20 | } // namespace trpc 21 | -------------------------------------------------------------------------------- /examples/features/filter/client/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_binary( 4 | name = "demo_client", 5 | srcs = ["demo_client.cc"], 6 | deps = [ 7 | "//examples/features/filter/common:invoke_stat_filter", 8 | "//examples/features/filter/common:user_rpc_filter", 9 | "//examples/helloworld:helloworld_proto", 10 | "@com_github_gflags_gflags//:gflags", 11 | "@trpc_cpp//trpc/client:make_client_context", 12 | "@trpc_cpp//trpc/client:trpc_client", 13 | "@trpc_cpp//trpc/common:runtime_manager", 14 | "@trpc_cpp//trpc/common:trpc_plugin", 15 | "@trpc_cpp//trpc/future:future_utility", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /examples/features/http/server/trpc_cpp_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | fiber: 4 | - instance_name: fiber_instance 5 | 6 | server: 7 | app: test 8 | server: test1 9 | service: 10 | - name: default_http_service 11 | network: tcp 12 | ip: 0.0.0.0 13 | port: 24856 14 | protocol: http 15 | 16 | plugins: 17 | log: 18 | default: 19 | - name: default 20 | min_level: 2 # 0-trace, 1-debug, 2-info, 3-warn, 4-error, 5-critical 21 | format: "[%Y-%m-%d %H:%M:%S.%e] [thread %t] [%l] [%@] %v" 22 | mode: 1 # 1-sync 2-async, 3-fast 23 | sinks: 24 | local_file: 25 | eol: true 26 | filename: http_server.log -------------------------------------------------------------------------------- /trpc/admin/perl_tools/pprof.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include 17 | 18 | namespace trpc::admin { 19 | 20 | /// @brief Copy content of perl scripts for performance profiling. 21 | void PprofPerl(std::string *output); 22 | 23 | } // namespace trpc::admin 24 | -------------------------------------------------------------------------------- /trpc/common/coroutine/trpc/trpc_task_executer.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/common/coroutine/trpc/trpc_task_executor.h" 17 | 18 | namespace trpc::coroutine { 19 | 20 | using TrpcTaskExecuter = TrpcTaskExecutor; 21 | 22 | } // namespace trpc::coroutine 23 | -------------------------------------------------------------------------------- /trpc/config/testing/test_load.json: -------------------------------------------------------------------------------- 1 | { 2 | "integer": -42, 3 | "unsigned_integer": 123, 4 | "float": 3.14, 5 | "boolean": true, 6 | "string": "Hello, World!", 7 | "array": [1, 2, 3, 4, 5], 8 | "nested_object": { 9 | "key1": "value1", 10 | "key2": { 11 | "sub_key1": 1, 12 | "sub_key2": false 13 | }, 14 | "key3": [ 15 | { 16 | "name": "Alice", 17 | "age": 30 18 | }, 19 | { 20 | "name": "Bob", 21 | "age": 25 22 | } 23 | ] 24 | }, 25 | "mixed": { 26 | "key1": ["item1", 333], 27 | "key2": ["item2", 444] 28 | }, 29 | "nested_list": [ 30 | ["nested_item1", 111], 31 | ["nested_item2", 222] 32 | ] 33 | } -------------------------------------------------------------------------------- /trpc/compressor/zlib/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "zlib_compressor", 7 | hdrs = ["zlib_compressor.h"], 8 | deps = [ 9 | "//trpc/compressor", 10 | "//trpc/compressor:compressor_type", 11 | "//trpc/compressor/common:zlib_util", 12 | ], 13 | ) 14 | 15 | cc_test( 16 | name = "zlib_compressor_test", 17 | srcs = ["zlib_compressor_test.cc"], 18 | deps = [ 19 | ":zlib_compressor", 20 | "//trpc/compressor/testing:compressor_testing", 21 | "@com_google_googletest//:gtest", 22 | "@com_google_googletest//:gtest_main", 23 | "@zlib", 24 | ], 25 | ) 26 | -------------------------------------------------------------------------------- /trpc/util/thread/internal/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "memory_barrier", 7 | srcs = ["memory_barrier.cc"], 8 | hdrs = ["memory_barrier.h"], 9 | deps = [ 10 | "//trpc/util:check", 11 | "//trpc/util/internal:never_destroyed", 12 | "//trpc/util/log:logging", 13 | ], 14 | ) 15 | 16 | cc_library( 17 | name = "object_array", 18 | hdrs = ["object_array.h"], 19 | deps = [ 20 | "//trpc/util:align", 21 | "//trpc/util:function", 22 | "//trpc/util:likely", 23 | "//trpc/util/internal:never_destroyed", 24 | "//trpc/util/log:logging", 25 | ], 26 | ) 27 | -------------------------------------------------------------------------------- /trpc/naming/common/constants.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | namespace trpc::naming { 17 | 18 | /// Key of instance's metadata 19 | constexpr char kNodeSetName[] = "internal-set-name"; 20 | constexpr char kNodeContainerName[] = "container_name"; 21 | 22 | } // namespace trpc::naming 23 | -------------------------------------------------------------------------------- /trpc/util/likely.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #if __GNUC__ 17 | #define TRPC_LIKELY(expr) (__builtin_expect(!!(expr), 1)) 18 | #define TRPC_UNLIKELY(expr) (__builtin_expect(!!(expr), 0)) 19 | #else 20 | #define TRPC_LIKELY(expr) (expr) 21 | #define TRPC_UNLIKELY(expr) (expr) 22 | #endif 23 | -------------------------------------------------------------------------------- /examples/features/http_rpc/server/trpc_cpp_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | fiber: 4 | - instance_name: fiber_instance 5 | 6 | server: 7 | app: test 8 | server: test1 9 | service: 10 | - name: trpc.test.helloworld.Greeter 11 | network: tcp 12 | ip: 0.0.0.0 13 | port: 24857 14 | protocol: trpc_over_http 15 | 16 | plugins: 17 | log: 18 | default: 19 | - name: default 20 | min_level: 2 # 0-trace, 1-debug, 2-info, 3-warn, 4-error, 5-critical 21 | format: "[%Y-%m-%d %H:%M:%S.%e] [thread %t] [%l] [%@] %v" 22 | mode: 1 # 1-sync 2-async, 3-fast 23 | sinks: 24 | local_file: 25 | eol: true 26 | filename: http_rpc_server.log -------------------------------------------------------------------------------- /trpc/runtime/iomodel/reactor/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "event_handler", 7 | srcs = ["event_handler.cc"], 8 | hdrs = ["event_handler.h"], 9 | deps = [ 10 | "//trpc/util:ref_ptr", 11 | ], 12 | ) 13 | 14 | cc_library( 15 | name = "poller", 16 | hdrs = ["poller.h"], 17 | deps = [ 18 | ":event_handler", 19 | "//trpc/util:function", 20 | ], 21 | ) 22 | 23 | cc_library( 24 | name = "reactor", 25 | hdrs = ["reactor.h"], 26 | deps = [ 27 | ":event_handler", 28 | "//trpc/runtime/threadmodel/common:timer_task", 29 | "//trpc/util:function", 30 | ], 31 | ) 32 | -------------------------------------------------------------------------------- /examples/features/grpc_stream/server/trpc_cpp_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | fiber: 4 | - instance_name: fiber_instance 5 | 6 | server: 7 | app: test 8 | server: helloworld 9 | service: 10 | - name: trpc.test.helloworld.RouteGuide 11 | network: tcp 12 | ip: 0.0.0.0 13 | port: 50051 14 | protocol: grpc 15 | 16 | plugins: 17 | log: 18 | default: 19 | - name: default 20 | min_level: 2 # 0-trace, 1-debug, 2-info, 3-warn, 4-error, 5-critical 21 | format: "[%Y-%m-%d %H:%M:%S.%e] [thread %t] [%l] [%@] %v" 22 | mode: 1 # 1-sync 2-async, 3-fast 23 | sinks: 24 | local_file: 25 | eol: true 26 | filename: grpc_stream_server.log -------------------------------------------------------------------------------- /trpc/common/coroutine/task_executer.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/common/coroutine/task_executor.h" 17 | 18 | namespace trpc::coroutine { 19 | 20 | // for compatible 21 | template 22 | using TaskExecuter = TaskExecutor; 23 | 24 | } // namespace trpc::coroutine 25 | -------------------------------------------------------------------------------- /trpc/stream/stream_handler_manager.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | namespace trpc::stream { 17 | 18 | /// @brief Initializes the stream handler. 19 | bool InitStreamHandler(); 20 | 21 | /// @brief Destroys the stream handler. 22 | void DestroyStreamHandler(); 23 | 24 | } // namespace trpc::stream 25 | -------------------------------------------------------------------------------- /trpc/transport/common/io_handler_manager.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | namespace trpc { 17 | 18 | /// @brief Initilize io handlers which used by framework 19 | bool InitIoHandler(); 20 | 21 | /// @brief Destroy all registered io handlers 22 | void DestroyIoHandler(); 23 | 24 | } // namespace trpc 25 | -------------------------------------------------------------------------------- /examples/features/thirdparty_protocol/server/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_binary( 4 | name = "demo_server", 5 | srcs = ["demo_server.cc"], 6 | linkopts = [ 7 | "-ldl", 8 | ], 9 | deps = [ 10 | "//examples/features/thirdparty_protocol/common:demo_protocol", 11 | "//examples/features/thirdparty_protocol/common:demo_server_codec", 12 | "@trpc_cpp//trpc/common:trpc_app", 13 | "@trpc_cpp//trpc/common:trpc_plugin", 14 | "@trpc_cpp//trpc/server:method", 15 | "@trpc_cpp//trpc/server:non_rpc_method_handler", 16 | "@trpc_cpp//trpc/server:non_rpc_service_impl", 17 | "@trpc_cpp//trpc/server:non_rpc_service_method", 18 | ], 19 | ) -------------------------------------------------------------------------------- /trpc/compressor/snappy/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "snappy_compressor", 7 | srcs = ["snappy_compressor.cc"], 8 | hdrs = ["snappy_compressor.h"], 9 | deps = [ 10 | "//trpc/compressor", 11 | "//trpc/compressor/common:util", 12 | "@com_github_google_snappy//:snappy", 13 | ], 14 | ) 15 | 16 | cc_test( 17 | name = "snappy_compressor_test", 18 | srcs = ["snappy_compressor_test.cc"], 19 | deps = [ 20 | ":snappy_compressor", 21 | "//trpc/compressor/testing:compressor_testing", 22 | "@com_google_googletest//:gtest", 23 | "@com_google_googletest//:gtest_main", 24 | ], 25 | ) 26 | -------------------------------------------------------------------------------- /examples/features/filter/server/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_binary( 4 | name = "demo_server", 5 | srcs = ["demo_server.cc"], 6 | linkopts = [ 7 | "-ldl", 8 | ] + select({ 9 | "@trpc_cpp//trpc:trpc_enable_profiler": ["/usr/lib64/libtcmalloc_and_profiler.so"], 10 | "//conditions:default": [], 11 | }), 12 | deps = [ 13 | "//examples/helloworld:helloworld_proto", 14 | "//examples/features/filter/common:invoke_stat_filter", 15 | "//examples/features/filter/common:user_rpc_filter", 16 | "@trpc_cpp//trpc/common:status", 17 | "@trpc_cpp//trpc/common:trpc_app", 18 | "@trpc_cpp//trpc/common/logging:trpc_logging", 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /examples/features/http_upload_download/server/trpc_cpp_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | threadmodel: 3 | fiber: 4 | - instance_name: fiber_instance 5 | 6 | server: 7 | app: test 8 | server: test1 9 | service: 10 | - name: http_upload_download_service 11 | network: tcp 12 | ip: 0.0.0.0 13 | port: 24858 14 | protocol: http 15 | 16 | plugins: 17 | log: 18 | default: 19 | - name: default 20 | min_level: 2 # 0-trace, 1-debug, 2-info, 3-warn, 4-error, 5-critical 21 | format: "[%Y-%m-%d %H:%M:%S.%e] [thread %t] [%l] [%@] %v" 22 | mode: 1 # 1-sync 2-async, 3-fast 23 | sinks: 24 | local_file: 25 | eol: true 26 | filename: http_upload_download_server.log 27 | -------------------------------------------------------------------------------- /test/end2end/unary/rpcz/conf/rpcz_client_fiber.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 0.0.0.0 3 | threadmodel: 4 | # Just cooperate with proxy_fiber, client no need to run in fiber. 5 | default: 6 | - instance_name: default_instance 7 | io_handle_type: merge 8 | io_thread_num: 4 9 | 10 | client: 11 | service: 12 | - name: rpcz_client 13 | selector_name: direct 14 | target: 127.0.0.1:15005 15 | protocol: trpc 16 | network: tcp 17 | conn_type: long 18 | is_conn_complex: true 19 | timeout: 1000 20 | - name: http_client 21 | selector_name: direct 22 | target: 127.0.0.1:32113 23 | protocol: http 24 | network: tcp 25 | conn_type: long 26 | timeout: 1000 27 | -------------------------------------------------------------------------------- /trpc/admin/js/flot_min_js.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | namespace trpc::admin { 17 | 18 | /// @brief Returns a piece of flot-min.js. 19 | /// flot.js, under MIT license, https://github.com/flot/flot/blob/master/LICENSE.txt 20 | /// Version: 0.8.3. 21 | const char* FlotMinJs(); 22 | 23 | } // namespace trpc::admin 24 | -------------------------------------------------------------------------------- /trpc/transport/client/preallocation_option.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/transport/common/transport_message_common.h" 17 | 18 | namespace trpc { 19 | 20 | /// @brief Pre-allocate connection option 21 | struct PreallocationOption { 22 | NodeAddr node_addr; 23 | }; 24 | 25 | } // namespace trpc 26 | -------------------------------------------------------------------------------- /trpc/util/thread/memory_barrier.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/util/thread/internal/memory_barrier.h" 17 | 18 | namespace trpc { 19 | 20 | /// @brief For details, please refer to `internal::MemoryBarrier` 21 | inline void MemoryBarrier() { internal::MemoryBarrier(); } 22 | 23 | } // namespace trpc 24 | -------------------------------------------------------------------------------- /examples/features/trpc_stream_forward/client/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_binary( 6 | name = "client", 7 | srcs = ["client.cc"], 8 | linkopts = ["-ldl"], 9 | deps = [ 10 | "//examples/features/trpc_stream_forward/proxy:stream_forward_proto", 11 | "@trpc_cpp//trpc/client:make_client_context", 12 | "@trpc_cpp//trpc/client:trpc_client", 13 | "@trpc_cpp//trpc/common:runtime_manager", 14 | "@trpc_cpp//trpc/common:status", 15 | "@trpc_cpp//trpc/common:trpc_plugin", 16 | "@trpc_cpp//trpc/common/config:trpc_config", 17 | "@trpc_cpp//trpc/coroutine:fiber", 18 | "@trpc_cpp//trpc/util/log:logging", 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /cmake/tools/copy_fmt_to_spdlog.sh: -------------------------------------------------------------------------------- 1 | # 2 | # 3 | # Tencent is pleased to support the open source community by making tRPC available. 4 | # 5 | # Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | # All rights reserved. 7 | # 8 | # If you have downloaded a copy of the tRPC source code from Tencent, 9 | # please note that tRPC source code is licensed under the Apache 2.0 License, 10 | # A copy of the Apache 2.0 License is included in this file. 11 | # 12 | # 13 | 14 | TRPC_ROOT_PATH=$1 15 | 16 | # override fmt lib in spdlog to avoid conflict 17 | if [ -d "${TRPC_ROOT_PATH}/cmake_third_party/fmt/include/fmt/" ]; then 18 | cp -rfp ${TRPC_ROOT_PATH}/cmake_third_party/fmt/include/fmt/* ${TRPC_ROOT_PATH}/cmake_third_party/spdlog/include/spdlog/fmt/bundled/ 19 | fi 20 | -------------------------------------------------------------------------------- /examples/features/trpc_async_stream/server/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_binary( 6 | name = "trpc_async_stream_server", 7 | srcs = ["stream_server.cc"], 8 | linkopts = [ 9 | "-ldl", 10 | ], 11 | deps = [ 12 | ":stream_service", 13 | "@trpc_cpp//trpc/common:trpc_app", 14 | "@trpc_cpp//trpc/util/log:logging", 15 | ], 16 | ) 17 | 18 | cc_library( 19 | name = "stream_service", 20 | srcs = ["stream_service.cc"], 21 | hdrs = ["stream_service.h"], 22 | deps = [ 23 | "//examples/features/trpc_stream/server:stream_proto", 24 | "@trpc_cpp//trpc/common:status", 25 | "@trpc_cpp//trpc/util/log:logging", 26 | ], 27 | ) -------------------------------------------------------------------------------- /test/end2end/unary/rpcz/conf/rpcz_client_separate.yaml: -------------------------------------------------------------------------------- 1 | global: 2 | local_ip: 0.0.0.0 3 | threadmodel: 4 | # Just cooperate with proxy_separate, client no need to run in separate. 5 | default: 6 | - instance_name: default_instance 7 | io_handle_type: merge 8 | io_thread_num: 4 9 | 10 | client: 11 | service: 12 | - name: rpcz_client 13 | selector_name: direct 14 | target: 127.0.0.1:15003 15 | protocol: trpc 16 | network: tcp 17 | conn_type: long 18 | is_conn_complex: true 19 | timeout: 1000 20 | - name: http_client 21 | selector_name: direct 22 | target: 127.0.0.1:32112 23 | protocol: http 24 | network: tcp 25 | conn_type: long 26 | timeout: 1000 27 | -------------------------------------------------------------------------------- /trpc/admin/js/jquery_min_js.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | namespace trpc::admin { 17 | 18 | /// @brief Returns a piece of jquery-min.js. 19 | /// jquery.js, under MIT license, https://github.com/jquery/jquery/blob/main/LICENSE.txt 20 | /// Version: 1.8.3. 21 | const char* JqueryMinJs(); 22 | 23 | } // namespace trpc::admin 24 | -------------------------------------------------------------------------------- /trpc/admin/js/viz_min_js.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | namespace trpc::admin { 17 | 18 | /// @brief Returns a piece of viz-min.js. 19 | /// viz.js, under MIT license, https://github.com/viz-js/viz.js/blob/master/LICENSE 20 | /// Version: 1.8.0 (probably). 21 | const char* VizMinJs(); 22 | 23 | } // namespace trpc::admin 24 | -------------------------------------------------------------------------------- /trpc/util/thread/thread_pool_option.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | namespace trpc { 17 | 18 | /// @brief Thread pool initialization parameters 19 | struct ThreadPoolOption { 20 | std::size_t thread_num = 1; 21 | std::size_t task_queue_size = 10000; 22 | bool bind_core = false; 23 | }; 24 | 25 | } // namespace trpc 26 | -------------------------------------------------------------------------------- /examples/features/rpcz/proxy/rpcz_proxy.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/common/trpc_app.h" 17 | 18 | namespace trpc::examples { 19 | 20 | class RpczServer: public trpc::TrpcApp { 21 | public: 22 | int Initialize() override; 23 | 24 | void Destroy() override; 25 | }; 26 | 27 | } // namespace trpc::examples 28 | -------------------------------------------------------------------------------- /examples/features/tvar/server/tvar_server.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include "trpc/common/trpc_app.h" 17 | 18 | namespace trpc::examples { 19 | 20 | class TvarServer: public trpc::TrpcApp { 21 | public: 22 | int Initialize() override; 23 | 24 | void Destroy() override; 25 | }; 26 | 27 | } // namespace trpc::examples 28 | -------------------------------------------------------------------------------- /test/end2end/unary/rpcz/README.md: -------------------------------------------------------------------------------- 1 | # end2end testing 2 | ## unary 3 | ### rpcz 4 | Directory tree as shown below: 5 | ```text 6 | test/end2end/unary/rpcz 7 | -- conf 8 | | |-- BUILD 9 | | |-- rpcz_client_fiber.yaml 10 | | |-- rpcz_client_merge.yaml 11 | | |-- rpcz_client_separate.yaml 12 | | |-- rpcz_proxy_fiber.yaml 13 | | |-- rpcz_proxy_merge.yaml 14 | | |-- rpcz_proxy_separate.yaml 15 | | |-- rpcz_real_server_fiber.yaml 16 | | |-- rpcz_real_server_merge.yaml 17 | | |-- rpcz_real_server_separate.yaml 18 | |-- BUILD 19 | |-- README.md 20 | |-- real_server.cc 21 | |-- real_server.h 22 | |-- real_server.proto 23 | |-- rpcz_fixture.cc 24 | |-- rpcz_fixture.h 25 | |-- rpcz_server.cc 26 | |-- rpcz_server.h 27 | |-- rpcz_test.cc 28 | |-- rpcz.proto 29 | ``` 30 | -------------------------------------------------------------------------------- /trpc/util/algorithm/power_of_two.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | #include 17 | 18 | namespace trpc { 19 | 20 | /// @brief Round up to the nearest power of 2. 21 | /// @param n input data. 22 | /// @return the smallest power of 2 greater than n. 23 | std::size_t RoundUpPowerOf2(std::size_t n); 24 | 25 | } // namespace trpc 26 | -------------------------------------------------------------------------------- /examples/features/prometheus/client/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_binary( 6 | name = "client", 7 | srcs = ["client.cc"], 8 | defines = [] + select({ 9 | "@trpc_cpp//trpc:trpc_include_prometheus": ["TRPC_BUILD_INCLUDE_PROMETHEUS"], 10 | "@trpc_cpp//trpc:include_metrics_prometheus": ["TRPC_BUILD_INCLUDE_PROMETHEUS"], 11 | "//conditions:default": [], 12 | }), 13 | deps = [ 14 | "//examples/features/prometheus/proxy:forward_proto", 15 | "@trpc_cpp//trpc/client:make_client_context", 16 | "@trpc_cpp//trpc/client:trpc_client", 17 | "@trpc_cpp//trpc/common:runtime_manager", 18 | "@com_github_gflags_gflags//:gflags", 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /examples/features/trpc_flatbuffers/run_cmake.sh: -------------------------------------------------------------------------------- 1 | mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j8 && cd - 2 | mkdir -p examples/features/trpc_flatbuffers/build && cd examples/features/trpc_flatbuffers/build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j8 && cd - 3 | 4 | echo "begin" 5 | examples/features/trpc_flatbuffers/build/demoserver --config=./examples/features/trpc_flatbuffers/server/trpc_cpp_fiber.yaml & 6 | sleep 1 7 | examples/features/trpc_flatbuffers/build/forwardserver --config=./examples/features/trpc_flatbuffers/proxy/trpc_cpp_fiber.yaml & 8 | sleep 1 9 | examples/features/trpc_flatbuffers/build/client --client_config=./examples/features/trpc_flatbuffers/client/trpc_cpp_fiber.yaml 10 | 11 | killall demoserver 12 | killall forwardserver 13 | -------------------------------------------------------------------------------- /trpc/admin/js/viz_min_js_test.cc: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #include "trpc/admin/js/viz_min_js.h" 15 | 16 | #include 17 | 18 | #include "gtest/gtest.h" 19 | 20 | namespace trpc::testing { 21 | 22 | TEST(VizMinJsTest, Test) { 23 | const char *js = admin::VizMinJs(); 24 | EXPECT_GE(strlen(js), 100); 25 | } 26 | 27 | } // namespace trpc::testing 28 | -------------------------------------------------------------------------------- /trpc/serialization/trpc_serialization.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | namespace trpc::serialization { 17 | 18 | /// @brief Initialize and register serialization plugins used internally by the framework 19 | bool Init(); 20 | 21 | /// @brief Destroy all serialization plugins 22 | void Destroy(); 23 | 24 | } // namespace trpc::serialization 25 | -------------------------------------------------------------------------------- /trpc/transport/common/connection_handler_manager.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #pragma once 15 | 16 | namespace trpc { 17 | 18 | /// @brief Initilize connection handlers which used by framework 19 | bool InitConnectionHandler(); 20 | 21 | /// @brief Destroy all registered connection handlers 22 | void DestroyConnectionHandler(); 23 | 24 | } // namespace trpc 25 | -------------------------------------------------------------------------------- /trpc/transport/common/io_handler_manager_test.cc: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Tencent is pleased to support the open source community by making tRPC available. 4 | // 5 | // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 | // All rights reserved. 7 | // 8 | // If you have downloaded a copy of the tRPC source code from Tencent, 9 | // please note that tRPC source code is licensed under the Apache 2.0 License, 10 | // A copy of the Apache 2.0 License is included in this file. 11 | // 12 | // 13 | 14 | #include "trpc/transport/common/io_handler_manager.h" 15 | 16 | #include "gtest/gtest.h" 17 | 18 | namespace trpc::testing { 19 | 20 | TEST(IoHandlerManagerTest, All) { 21 | ASSERT_TRUE(InitIoHandler()); 22 | 23 | DestroyIoHandler(); 24 | } 25 | 26 | } // namespace trpc::testing 27 | -------------------------------------------------------------------------------- /trpc/transport/common/ssl/cert/ca/xxops-com-chain/mk_xxops_com_csr_cert.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | ROOT_KEY="root-ca.key" 4 | ROOT_CERT="root-ca.crt" 5 | 6 | KEY_NAME='xxops-com.key' 7 | CERT_NAME='xxops-com.crt' 8 | CSR_NAME='xxops-com.csr' 9 | 10 | ## generate rsa key 11 | openssl genrsa -out ${KEY_NAME} 2048 12 | 13 | ## create sefl-signed certificate 14 | openssl req -new -key ${KEY_NAME} -sha256 -subj "/C=CN/S=Guangdong Province/L=Shenzhen/O=xxops Org, Inc./CN=*.xxops.com" -out ${CSR_NAME} 15 | 16 | openssl x509 -req -in ${CSR_NAME} -CA ${ROOT_CERT} -CAkey ${ROOT_KEY} -CAcreateserial -out ${CERT_NAME} -days 1095 -sha256 17 | 18 | ## view csr 19 | openssl req -in ${CSR_NAME} -noout -text 20 | 21 | ## view certificate 22 | openssl x509 -in ${CERT_NAME} -noout -text 23 | -------------------------------------------------------------------------------- /examples/features/http/client/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_binary( 6 | name = "client", 7 | srcs = ["client.cc"], 8 | linkopts = ["-ldl"], 9 | deps = [ 10 | "@com_github_tencent_rapidjson//:rapidjson", 11 | "@trpc_cpp//trpc/client:make_client_context", 12 | "@trpc_cpp//trpc/client:trpc_client", 13 | "@trpc_cpp//trpc/client/http:http_service_proxy", 14 | "@trpc_cpp//trpc/common:runtime_manager", 15 | "@trpc_cpp//trpc/common:status", 16 | "@trpc_cpp//trpc/common:trpc_plugin", 17 | "@trpc_cpp//trpc/common/config:trpc_config", 18 | "@trpc_cpp//trpc/coroutine:fiber", 19 | "@trpc_cpp//trpc/util/log:logging", 20 | ], 21 | ) 22 | -------------------------------------------------------------------------------- /examples/features/http_rpc/client/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_binary( 6 | name = "client", 7 | srcs = ["client.cc"], 8 | linkopts = ["-ldl"], 9 | deps = [ 10 | "//examples/helloworld:helloworld_proto", 11 | "@trpc_cpp//trpc/client:make_client_context", 12 | "@trpc_cpp//trpc/client:trpc_client", 13 | "@trpc_cpp//trpc/client/http:http_service_proxy", 14 | "@trpc_cpp//trpc/common:runtime_manager", 15 | "@trpc_cpp//trpc/common:status", 16 | "@trpc_cpp//trpc/common:trpc_plugin", 17 | "@trpc_cpp//trpc/common/config:trpc_config", 18 | "@trpc_cpp//trpc/coroutine:fiber", 19 | "@trpc_cpp//trpc/util/log:logging", 20 | ], 21 | ) 22 | --------------------------------------------------------------------------------