Go to the documentation of this file.
23 #include <condition_variable>
28 #include "absl/flags/flag.h"
36 #include "src/proto/grpc/testing/empty.pb.h"
37 #include "src/proto/grpc/testing/messages.pb.h"
38 #include "src/proto/grpc/testing/test.grpc.pb.h"
42 ABSL_FLAG(
int32_t, control_port, 0,
"Server port for controlling the server.");
44 "Server port for raw tcp connections. All incoming "
45 "connections will be closed immediately.");
51 using grpc::testing::Empty;
54 using grpc::testing::ReconnectService;
79 std::unique_lock<std::mutex> lock(
mu_);
91 request->max_reconnect_backoff_ms();
109 std::lock_guard<std::mutex> lock(
mu_);
116 double expected_backoff = 1000.0;
117 const double kTransmissionDelay = 100.0;
118 const double kBackoffMultiplier = 1.6;
119 const double kJitterFactor = 0.2;
128 double min_backoff = expected_backoff * (1 - kJitterFactor);
129 double max_backoff = expected_backoff * (1 + kJitterFactor);
130 if (backoff < min_backoff - kTransmissionDelay ||
131 backoff > max_backoff + kTransmissionDelay) {
135 expected_backoff *= kBackoffMultiplier;
137 expected_backoff > kMaxBackoffMs ? kMaxBackoffMs : expected_backoff;
143 std::lock_guard<std::mutex> lock(
mu_);
155 std::condition_variable
cv_;
177 int main(
int argc,
char** argv) {
void InitTest(int *argc, char ***argv, bool remove_flags)
std::chrono::duration< std::int_fast64_t > seconds
void reconnect_server_destroy(reconnect_server *server)
int main(int argc, char **argv)
void reconnect_server_clear_timestamps(reconnect_server *server)
static void start_server(void)
std::string server_address("0.0.0.0:10000")
reconnect_server tcp_server_
std::unique_ptr< Server > server
static void signal(notification *n)
A builder class for the creation and startup of grpc::Server instances.
GPRAPI gpr_timespec gpr_time_sub(gpr_timespec a, gpr_timespec b)
void Verify(ReconnectInfo *response)
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
ABSL_FLAG(int32_t, control_port, 0, "Server port for controlling the server.")
int max_reconnect_backoff_ms
GPRAPI int32_t gpr_time_to_millis(gpr_timespec timespec)
Status Start(ServerContext *, const ReconnectParams *request, Empty *) override
ABSL_MUST_USE_RESULT T GetFlag(const absl::Flag< T > &flag)
static void sigint_handler(int)
void reconnect_server_poll(reconnect_server *server, int seconds)
Status Stop(ServerContext *, const Empty *, ReconnectInfo *response) override
GRPC_CUSTOM_UTIL_STATUS Status
void reconnect_server_start(reconnect_server *server, int port)
~ReconnectServiceImpl() override
std::shared_ptr< ServerCredentials > InsecureServerCredentials()
ReconnectServiceImpl(int retry_port)
void reconnect_server_init(reconnect_server *server)
__attribute__((deprecated("Please use GRPCProtoMethod."))) @interface ProtoMethod NSString * service
std::condition_variable cv_
grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:00