Go to the documentation of this file.
21 #include "absl/flags/flag.h"
22 #include "absl/strings/str_cat.h"
23 #include "absl/synchronization/mutex.h"
39 #include "src/proto/grpc/testing/empty.pb.h"
40 #include "src/proto/grpc/testing/messages.pb.h"
41 #include "src/proto/grpc/testing/test.grpc.pb.h"
48 "Server port for maintenance if --security is \"secure\".");
50 "Server ID to include in responses.");
52 "If true, XdsServerCredentials are used, InsecureServerCredentials "
60 using grpc::testing::Empty;
64 using grpc::testing::TestService;
65 using grpc::testing::XdsUpdateHealthService;
98 grpc::health::v1::HealthCheckResponse::SERVING);
105 grpc::health::v1::HealthCheckResponse::NOT_SERVING);
113 void RunServer(
bool secure_mode,
const int port,
const int maintenance_port,
115 std::unique_ptr<Server> xds_enabled_server;
116 std::unique_ptr<Server>
server;
120 "", grpc::health::v1::HealthCheckResponse::SERVING);
122 "grpc.testing.TestService",
123 grpc::health::v1::HealthCheckResponse::SERVING);
125 "grpc.testing.XdsUpdateHealthService",
126 grpc::health::v1::HealthCheckResponse::SERVING);
140 builder.RegisterService(&update_health_service);
150 builder.RegisterService(&update_health_service);
161 int main(
int argc,
char** argv) {
165 if (hostname ==
nullptr) {
166 std::cout <<
"Failed to get hostname, terminating" << std::endl;
171 std::cout <<
"Invalid port, terminating" << std::endl;
174 int maintenance_port =
absl::GetFlag(FLAGS_maintenance_port);
175 if (maintenance_port == 0) {
176 std::cout <<
"Invalid maintenance port, terminating" << std::endl;
void InitTest(int *argc, char ***argv, bool remove_flags)
Status SetNotServing(ServerContext *, const Empty *, Empty *) override
Status EmptyCall(ServerContext *context, const Empty *, Empty *) override
TestServiceImpl(const std::string &hostname)
std::string StrCat(const AlphaNum &a, const AlphaNum &b)
virtual std::unique_ptr< grpc::Server > BuildAndStart()
void EnableDefaultHealthCheckService(bool enable)
XdsUpdateHealthServiceImpl(HealthCheckServiceImpl *health_check_service)
std::shared_ptr< ServerCredentials > XdsServerCredentials(const std::shared_ptr< ServerCredentials > &fallback_credentials)
Builds Xds ServerCredentials given fallback credentials.
Status UnaryCall(ServerContext *context, const SimpleRequest *, SimpleResponse *response) override
ServerBuilder & RegisterService(grpc::Service *service)
bool health_check_service
std::unique_ptr< Server > server
ServerBuilder & AddListeningPort(const std::string &addr_uri, std::shared_ptr< grpc::ServerCredentials > creds, int *selected_port=nullptr)
Status SetServing(ServerContext *, const Empty *, Empty *) override
char * grpc_gethostname()
A builder class for the creation and startup of grpc::Server instances.
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
void SetAll(health::v1::HealthCheckResponse::ServingStatus status)
ABSL_MUST_USE_RESULT T GetFlag(const absl::Flag< T > &flag)
GRPC_CUSTOM_UTIL_STATUS Status
void AddAdminServices(grpc::ServerBuilder *builder)
std::shared_ptr< ServerCredentials > InsecureServerCredentials()
grpc::ClientContext context
__attribute__((deprecated("Please use GRPCProtoMethod."))) @interface ProtoMethod NSString * service
int main(int argc, char **argv)
void InitProtoReflectionServerBuilderPlugin()
HealthCheckServiceImpl *const health_check_service_
ABSL_FLAG(int32_t, port, 8080, "Server port for service.")
void RunServer(bool secure_mode, const int port, const int maintenance_port, const std::string &hostname)
grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:59