The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#) https://grpc.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.1 KiB

10 years ago
/*
*
* Copyright 2015 gRPC authors.
10 years ago
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
10 years ago
*
* http://www.apache.org/licenses/LICENSE-2.0
10 years ago
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
10 years ago
*
*/
#include <signal.h>
10 years ago
#include <chrono>
#include <thread>
#include <vector>
#include "absl/flags/flag.h"
#include <grpc/grpc.h>
#include <grpc/support/time.h>
#include "test/core/util/test_config.h"
#include "test/cpp/qps/qps_worker.h"
#include "test/cpp/util/test_config.h"
#include "test/cpp/util/test_credentials_provider.h"
10 years ago
ABSL_FLAG(int32_t, driver_port, 0, "Port for communication with driver");
ABSL_FLAG(int32_t, server_port, 0,
"Port for operation as a server, if not specified by the server "
"config message");
ABSL_FLAG(std::string, credential_type, grpc::testing::kInsecureCredentialsType,
"Credential type for communication with driver");
10 years ago
static bool got_sigint = false;
static void sigint_handler(int /*x*/) { got_sigint = true; }
10 years ago
namespace grpc {
namespace testing {
std::vector<grpc::testing::Server*>* g_inproc_servers = nullptr;
10 years ago
static void RunServer() {
QpsWorker worker(absl::GetFlag(FLAGS_driver_port),
absl::GetFlag(FLAGS_server_port),
absl::GetFlag(FLAGS_credential_type));
10 years ago
while (!got_sigint && !worker.Done()) {
10 years ago
gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_seconds(5, GPR_TIMESPAN)));
10 years ago
}
}
10 years ago
} // namespace testing
} // namespace grpc
10 years ago
10 years ago
int main(int argc, char** argv) {
grpc::testing::TestEnvironment env(argc, argv);
grpc::testing::InitTest(&argc, &argv, true);
10 years ago
signal(SIGINT, sigint_handler);
10 years ago
grpc::testing::RunServer();
10 years ago
return 0;
}