(原創)C/C++語言, 平臺是debian10, grpc版本:grpc-c++/1.25.0-dev grpc-c/8.0.0, 使用的例子是自帶的例子GreeterClientc++
grpc Unary模式下客戶端建立insecure channel的主要流程ui
graph TD; 001(main #greeter_client.cc:81 入口調用grpc::CreateChannel)-->002(grpc::CreateChannel #create_channel.h:30 調用::grpc_impl::CreateChannelImpl) 002-->003(grpc_impl::CreateChannelImpl #create_channel.cc:33 調用CreateCustomChannelImpl) 003-->004(grpc_impl::CreateCustomChannelImpl #create_channel.cc:50 初始化GrpcLibraryCodegen並最終調用grpc_init初始化核心模塊, 再調用CreateChannelImpl) 004-->005(grpc_impl::InsecureChannelCredentialsImpl::CreateChannelImpl #insecure_credentials.cc:37 調用CreateChannelWithInterceptors) 005-->006(grpc_impl::InsecureChannelCredentialsImpl::CreateChannelWithInterceptors insecure_credentials.cc:50 調用grpc_insecure_channel_create) 006-->007(grpc_insecure_channel_create #channel_create.cc:104 增長了grpc.client_channel_factory參數並調用CreateChannel) 007-->008(grpc_core::CreateChannel #channel_create.cc:67 增長了grpc.server_uri參數並調用grpc_channel_create) 008-->009(grpc_channel_create #channel.cc:286 調用grpc_init, 此處不會執行初始化,由於前面已經初始化了,建立並設置grpc_channel_stack_builder參數,建立ChannelzNode,最後調用 grpc_channel_create_with_builder) 009-->010(grpc_channel_create_with_builder #channel.cc:79 調用grpc_channel_stack_builder_finish完成channel建立並設置channel的變量) 010-->011(grpc_channel_stack_builder_finish #channel_stack_builder.cc:297 建立並初始化channel對應的grpc_channel_stack)