worker.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #include <signal.h>
20 
21 #include <chrono>
22 #include <thread>
23 #include <vector>
24 
25 #include "absl/flags/flag.h"
26 
27 #include <grpc/grpc.h>
28 #include <grpc/support/time.h>
29 
34 
35 ABSL_FLAG(int32_t, driver_port, 0, "Port for communication with driver");
37  "Port for operation as a server, if not specified by the server "
38  "config message");
40  "Credential type for communication with driver");
41 
42 static bool got_sigint = false;
43 
44 static void sigint_handler(int /*x*/) { got_sigint = true; }
45 
46 namespace grpc {
47 namespace testing {
48 
49 std::vector<grpc::testing::Server*>* g_inproc_servers = nullptr;
50 
51 static void RunServer() {
52  QpsWorker worker(absl::GetFlag(FLAGS_driver_port),
53  absl::GetFlag(FLAGS_server_port),
54  absl::GetFlag(FLAGS_credential_type));
55 
56  while (!got_sigint && !worker.Done()) {
59  }
60 }
61 
62 } // namespace testing
63 } // namespace grpc
64 
65 int main(int argc, char** argv) {
67  grpc::testing::InitTest(&argc, &argv, true);
68 
69  signal(SIGINT, sigint_handler);
70 
72 
73  return 0;
74 }
test_credentials_provider.h
GPR_TIMESPAN
@ GPR_TIMESPAN
Definition: gpr_types.h:45
grpc::testing::InitTest
void InitTest(int *argc, char ***argv, bool remove_flags)
Definition: test_config_cc.cc:28
testing
Definition: aws_request_signer_test.cc:25
ABSL_FLAG
ABSL_FLAG(int32_t, driver_port, 0, "Port for communication with driver")
generate.env
env
Definition: generate.py:37
grpc
Definition: grpcpp/alarm.h:33
worker
static void worker(void *arg)
Definition: threadpool.c:57
main
int main(int argc, char **argv)
Definition: worker.cc:65
server_port
static int server_port
Definition: bad_server_response_test.cc:86
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
qps_worker.h
time.h
grpc::testing::RunServer
void RunServer()
Definition: client_crash_test_server.cc:56
grpc::testing::kInsecureCredentialsType
const char kInsecureCredentialsType[]
Definition: test_credentials_provider.h:31
signal
static void signal(notification *n)
Definition: alts_tsi_handshaker_test.cc:107
worker
Definition: worker.py:1
gpr_sleep_until
GPRAPI void gpr_sleep_until(gpr_timespec until)
grpc.h
grpc::testing::g_inproc_servers
std::vector< grpc::testing::Server * > * g_inproc_servers
Definition: driver.cc:363
absl::GetFlag
ABSL_MUST_USE_RESULT T GetFlag(const absl::Flag< T > &flag)
Definition: abseil-cpp/absl/flags/flag.h:98
gpr_now
GPRAPI gpr_timespec gpr_now(gpr_clock_type clock)
test_config.h
gpr_time_add
GPRAPI gpr_timespec gpr_time_add(gpr_timespec a, gpr_timespec b)
Definition: src/core/lib/gpr/time.cc:135
got_sigint
static bool got_sigint
Definition: worker.cc:42
grpc::testing::TestEnvironment
Definition: test/core/util/test_config.h:54
test_config.h
gpr_time_from_millis
GPRAPI gpr_timespec gpr_time_from_millis(int64_t ms, gpr_clock_type clock_type)
Definition: src/core/lib/gpr/time.cc:119
GPR_CLOCK_REALTIME
@ GPR_CLOCK_REALTIME
Definition: gpr_types.h:39
int32_t
signed int int32_t
Definition: stdint-msvc2008.h:77
sigint_handler
static void sigint_handler(int)
Definition: worker.cc:44


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:53